mirror of
https://github.com/django/django.git
synced 2025-10-27 23:56:08 +00:00
Fixed #24397 -- Sped up rendering multiple model states.
Set apps.ready to False when rendering multiple models. This prevents that the cache on Model._meta is expired on all models after each time a single model is rendered. Prevented that Apps.clear_cache() refills the cache on Apps.get_models(), so that the wrong value cannot be cached when cloning a StateApps.
This commit is contained in:
committed by
Markus Holtermann
parent
180f75c2a0
commit
888c9b6429
@@ -326,8 +326,11 @@ class Apps(object):
|
||||
# the relation tree and the fields cache.
|
||||
self.get_models.cache_clear()
|
||||
if self.ready:
|
||||
for model in self.get_models(include_auto_created=True):
|
||||
model._meta._expire_cache()
|
||||
# Circumvent self.get_models() to prevent that the cache is refilled.
|
||||
# This particularly prevents that an empty value is cached while cloning.
|
||||
for app_config in self.app_configs.values():
|
||||
for model in app_config.get_models(include_auto_created=True):
|
||||
model._meta._expire_cache()
|
||||
|
||||
|
||||
apps = Apps(installed_apps=None)
|
||||
|
||||
Reference in New Issue
Block a user