id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 25520 Cascade delete of proxy model children fails with IntegrityErrors James Murty nobody "When deleting a concrete model based on proxy models, Django's deletion collector does not find M2M reverse relationships to proxy parents; it only finds these relationships for concrete parent models. This means that deleting a proxy-based model object with extant M2M relationships targeting a proxy parent will fail with integrity errors if you use a database like PostgreSQL that enforces foreign key constraints. The target model instance cannot be deleted because the M2M FK relationships are not also deleted at the same time, and would otherwise remain pointing to a non-existent record. This issue tends to affect users of django-polymorphic who rely more than most on proxy models, and has been reported in this context in #23076 I have created a Pull Requests based on the current master branch that adds unit tests demonstrating the issue when run against a database that enforces foreign key constrains, such as PostgreSQL: ​https://github.com/django/django/pull/5404 This issue also affects versions 1.7 and 1.8 and perhaps also earlier versions, but likely has not been encountered broadly because the use case that triggers it is somewhat unusual." Bug closed Database layer (models, ORM) dev Normal duplicate james@… tzanke@… jernej@… Unreviewed 0 0 0 0 0 0