Ticket #13416: django_ticket_13416.diff

File django_ticket_13416.diff, 1.0 KB (added by Ryan Fugger, 15 years ago)

Don't treat generic relations as nullable when building model delete cascade tree.

  • django/db/models/base.py

     
    606606            else:
    607607                # m2m-ish but with no through table? GenericRelation: cascade delete
    608608                for sub_obj in f.value_from_object(self).all():
    609                     # Generic relations not enforced by db constraints, thus we can set
    610                     # nullable=True, order does not matter
    611                     sub_obj._collect_sub_objects(seen_objs, self, True)
     609                    # Generic relations not enforced by db constraints, but don't
     610                    # set nullable=True because post_delete hook might rely on
     611                    # parent object being in db.
     612                    sub_obj._collect_sub_objects(seen_objs, self, False)
    612613
    613614        # Handle any ancestors (for the model-inheritance case). We do this by
    614615        # traversing to the most remote parent classes -- those with no parents
Back to Top