diff options
| author | Marten Kenbeek <marten.knbk@gmail.com> | 2015-02-22 04:26:17 +0100 |
|---|---|---|
| committer | Markus Holtermann <info@markusholtermann.eu> | 2015-03-08 13:54:49 +0100 |
| commit | 888c9b6429a44824078a49fb1ebacf2e950cd887 (patch) | |
| tree | b5265563422cb78a857453626b158ac88b13d2c3 /django/apps | |
| parent | 180f75c2a0d15e54a7088bd5cb7a57342da5661d (diff) | |
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.
Diffstat (limited to 'django/apps')
| -rw-r--r-- | django/apps/registry.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/django/apps/registry.py b/django/apps/registry.py index e75bb99cfe..164427d85f 100644 --- a/django/apps/registry.py +++ b/django/apps/registry.py @@ -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) |
