diff options
Diffstat (limited to 'django/db/models/base.py')
| -rw-r--r-- | django/db/models/base.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py index dec0316947..34b31b89af 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -437,7 +437,17 @@ class Model(object): else: sub_obj._collect_sub_objects(seen_objs, self.__class__, related.field.null) else: - for sub_obj in getattr(self, rel_opts_name).all(): + # To make sure we can access all elements, we can't use the + # normal manager on the related object. So we work directly + # with the descriptor object. + for cls in self.__class__.mro(): + if rel_opts_name in cls.__dict__: + rel_descriptor = cls.__dict__[rel_opts_name] + break + else: + raise AssertionError("Should never get here.") + delete_qs = rel_descriptor.delete_manager(self).all() + for sub_obj in delete_qs: sub_obj._collect_sub_objects(seen_objs, self.__class__, related.field.null) # Handle any ancestors (for the model-inheritance case). We do this by |
