Refs #31051 -- Made dumpdata do not sort dependencies if natural foreign keys are not used.

There is no need to sort dependencies when natural foreign keys are not
used.
This commit is contained in:
Matthijs Kooijman 2019-12-02 00:48:01 +01:00 committed by Mariusz Felisiak
parent 4f216e4f8e
commit 2e67e80fbe
1 changed files with 11 additions and 1 deletions

View File

@ -144,7 +144,17 @@ class Command(BaseCommand):
Collate the objects to be serialized. If count_only is True, just Collate the objects to be serialized. If count_only is True, just
count the number of objects to be serialized. count the number of objects to be serialized.
""" """
models = serializers.sort_dependencies(app_list.items(), allow_cycles=True) if use_natural_foreign_keys:
models = serializers.sort_dependencies(app_list.items(), allow_cycles=True)
else:
# There is no need to sort dependencies when natural foreign
# keys are not used.
models = []
for (app_config, model_list) in app_list.items():
if model_list is None:
models.extend(app_config.get_models())
else:
models.extend(model_list)
for model in models: for model in models:
if model in excluded_models: if model in excluded_models:
continue continue