Skip to content

Commit

Permalink
Fixed #33848 -- Optimized StateApps.clone().
Browse files Browse the repository at this point in the history
  • Loading branch information
iurisilvio authored and felixxm committed Jul 16, 2022
1 parent d4c5d2b commit f0fa2a3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions django/db/migrations/state.py
Expand Up @@ -680,10 +680,13 @@ def clone(self):
"""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
Expand Down

0 comments on commit f0fa2a3

Please sign in to comment.