diff --git a/django/core/management/commands/dumpdata.py b/django/core/management/commands/dumpdata.py index 14b9b00dfd..a76a6d02a4 100644 --- a/django/core/management/commands/dumpdata.py +++ b/django/core/management/commands/dumpdata.py @@ -137,10 +137,15 @@ def sort_dependencies(app_list): changed = False while model_dependencies: model, deps = model_dependencies.pop() - if all((d not in models or d in model_list) for d in deps): - # If all of the models in the dependency list are either already - # on the final model list, or not on the original serialization list, - # then we've found another model with all it's dependencies satisfied. + + # If all of the models in the dependency list are either already + # on the final model list, or not on the original serialization list, + # then we've found another model with all it's dependencies satisfied. + found = True + for candidate in ((d not in models or d in model_list) for d in deps): + if not candidate: + found = False + if found: model_list.append(model) changed = True else: @@ -152,4 +157,4 @@ def sort_dependencies(app_list): ) model_dependencies = skipped - return model_list + return model_list \ No newline at end of file