diff --git a/django/db/models/query.py b/django/db/models/query.py index 4fe185ed6e9..b08f3acd144 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -95,6 +95,8 @@ class CollectedObjects(object): while len(dealt_with) < len(models): found = False for model in models: + if model in dealt_with: + continue children = self.children.setdefault(model, []) if len([c for c in children if c not in dealt_with]) == 0: dealt_with[model] = None