diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2016-09-30 21:08:35 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-10-28 18:42:29 -0400 |
| commit | efcb7e1ebf2b852a442d00a31634438359eb4039 (patch) | |
| tree | cce88cc9cb2093fca4fe9a764bcce803d2be7d81 /django/db | |
| parent | 20be1918e77414837178d6bf1657068c8306d50c (diff) | |
Modified readiness check in AppConfig.get_model(s).
It was inconsistent with the equivalent check in Apps.get_model(s)
because I made incorrect assumptions when I wrote that code and
needlessly complicated readiness checks.
This is a backwards-incompatible change.
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/migrations/state.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py index 9cbf5659d4..60d192443b 100644 --- a/django/db/migrations/state.py +++ b/django/db/migrations/state.py @@ -239,6 +239,10 @@ class StateApps(Apps): app_configs = [AppConfigStub(label) for label in sorted(real_apps + list(app_labels))] super(StateApps, self).__init__(app_configs) + # The lock gets in the way of copying as implemented in clone(), which + # is called whenever Django duplicates a StateApps before updating it. + self._lock = None + self.render_multiple(list(models.values()) + self.real_models) # There shouldn't be any operations pending at this point. @@ -293,6 +297,9 @@ class StateApps(Apps): clone = StateApps([], {}) clone.all_models = copy.deepcopy(self.all_models) clone.app_configs = copy.deepcopy(self.app_configs) + # Set the pointer to the correct app registry. + for app_config in clone.app_configs.values(): + app_config.apps = clone # No need to actually clone them, they'll never change clone.real_models = self.real_models return clone @@ -301,6 +308,7 @@ class StateApps(Apps): self.all_models[app_label][model._meta.model_name] = model if app_label not in self.app_configs: self.app_configs[app_label] = AppConfigStub(app_label) + self.app_configs[app_label].apps = self self.app_configs[app_label].models = OrderedDict() self.app_configs[app_label].models[model._meta.model_name] = model self.do_pending_operations(model) |
