diff options
| author | Iuri de Silvio <iurisilvio@gmail.com> | 2022-07-15 14:45:52 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-07-16 10:12:32 +0200 |
| commit | f0fa2a3b49797f1e9830e2a0d2072119093b4452 (patch) | |
| tree | b54e42edf1eea76d96fa8b214892672c8ecfa471 | |
| parent | d4c5d2b52c897ccc07f04482d3f42f976a79223c (diff) | |
Fixed #33848 -- Optimized StateApps.clone().
| -rw-r--r-- | django/db/migrations/state.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py index ff5d0e93a9..ae55967383 100644 --- a/django/db/migrations/state.py +++ b/django/db/migrations/state.py @@ -680,10 +680,13 @@ class StateApps(Apps): """Return a clone of this registry.""" 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(): + + for app_label in self.app_configs: + app_config = AppConfigStub(app_label) app_config.apps = clone + app_config.import_models() + clone.app_configs[app_label] = app_config + # No need to actually clone them, they'll never change clone.real_models = self.real_models return clone |
