Ticket #11116: 11116_proxy_model_delete.diff

File 11116_proxy_model_delete.diff, 1.3 KB (added by Paul McLanahan, 15 years ago)

Possible fix

  • django/db/models/base.py

     
    541541        parent_stack = self._meta.parents.values()
    542542        while parent_stack:
    543543            link = parent_stack.pop()
    544             parent_obj = getattr(self, link.name)
    545             if parent_obj._meta.parents:
    546                 parent_stack.extend(parent_obj._meta.parents.values())
    547                 continue
    548             # At this point, parent_obj is base class (no ancestor models). So
    549             # delete it and all its descendents.
    550             parent_obj._collect_sub_objects(seen_objs)
     544            if link is not None:
     545                parent_obj = getattr(self, link.name)
     546                if parent_obj._meta.parents:
     547                    parent_stack.extend(parent_obj._meta.parents.values())
     548                    continue
     549                # At this point, parent_obj is base class (no ancestor models). So
     550                # delete it and all its descendents.
     551                parent_obj._collect_sub_objects(seen_objs)
    551552
    552553    def delete(self):
    553554        assert self._get_pk_val() is not None, "%s object can't be deleted because its %s attribute is set to None." % (self._meta.object_name, self._meta.pk.attname)
Back to Top