Loading django/db/models/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -538,7 +538,7 @@ class Model(object): # traversing to the most remote parent classes -- those with no parents # themselves -- and then adding those instances to the collection. That # will include all the child instances down to "self". parent_stack = self._meta.parents.values() parent_stack = [p for p in self._meta.parents.values() if p is not None] while parent_stack: link = parent_stack.pop() parent_obj = getattr(self, link.name) Loading tests/modeltests/proxy_models/models.py +9 −0 Original line number Diff line number Diff line Loading @@ -276,6 +276,15 @@ True >>> UserProxyProxy.objects.all() [<UserProxyProxy: Bruce>] # Proxy objects can be deleted >>> u2 = UserProxy.objects.create(name='George') >>> UserProxy.objects.all() [<UserProxy: Bruce>, <UserProxy: George>] >>> u2.delete() >>> UserProxy.objects.all() [<UserProxy: Bruce>] # We can still use `select_related()` to include related models in our querysets. >>> country = Country.objects.create(name='Australia') >>> state = State.objects.create(name='New South Wales', country=country) Loading Loading
django/db/models/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -538,7 +538,7 @@ class Model(object): # traversing to the most remote parent classes -- those with no parents # themselves -- and then adding those instances to the collection. That # will include all the child instances down to "self". parent_stack = self._meta.parents.values() parent_stack = [p for p in self._meta.parents.values() if p is not None] while parent_stack: link = parent_stack.pop() parent_obj = getattr(self, link.name) Loading
tests/modeltests/proxy_models/models.py +9 −0 Original line number Diff line number Diff line Loading @@ -276,6 +276,15 @@ True >>> UserProxyProxy.objects.all() [<UserProxyProxy: Bruce>] # Proxy objects can be deleted >>> u2 = UserProxy.objects.create(name='George') >>> UserProxy.objects.all() [<UserProxy: Bruce>, <UserProxy: George>] >>> u2.delete() >>> UserProxy.objects.all() [<UserProxy: Bruce>] # We can still use `select_related()` to include related models in our querysets. >>> country = Country.objects.create(name='Australia') >>> state = State.objects.create(name='New South Wales', country=country) Loading