summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2019-12-02 00:48:01 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-04-07 20:41:59 +0200
commit2e67e80fbe0accd5f256415ac28af8bd82eeaced (patch)
tree2466effa931c546c58d93b5952cd7e3d5ea760ee /django
parent4f216e4f8ea9bac61948cb63066cd4747f6d05fb (diff)
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.
Diffstat (limited to 'django')
-rw-r--r--django/core/management/commands/dumpdata.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/django/core/management/commands/dumpdata.py b/django/core/management/commands/dumpdata.py
index 247b0f20fd..df9eecc0f8 100644
--- a/django/core/management/commands/dumpdata.py
+++ b/django/core/management/commands/dumpdata.py
@@ -144,7 +144,17 @@ class Command(BaseCommand):
Collate the objects to be serialized. If count_only is True, just
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:
if model in excluded_models:
continue