Opened 12 years ago
Closed 12 years ago
#19838 closed Bug (fixed)
Deleting a protected fk relationships throws error 500 when deleting inlines
Reported by: | Rafael Ponieman | Owned by: | javimansilla |
---|---|---|---|
Component: | contrib.admin | Version: | 1.4 |
Severity: | Normal | Keywords: | sprints-django-ar |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Better explained with an example.
We have 3 models, Category, Subcategory and Item. Subcategory has a protected (on_delete=models.PROTECT) fk relationship to Category, and Item has a protected fk relationship to Subcategory.
When trying to delete a Category that has Subcategories, the Django admin displays a readable, understandable message explaining that the model instance has related models, so it can't be deleted. However, if the Subcategories are displayed as inlines in the Category admin, and one tries to delete a Subcategory that has related items, Django throws an uncatched error 500, instead of a human-readable message.
Change History (7)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 12 years ago
Keywords: | sprints-django-ar added |
---|
comment:5 by , 12 years ago
Has patch: | set |
---|
Pull request added: https://github.com/django/django/pull/797
comment:6 by , 12 years ago
comment:7 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
It is clear in the documentation that models.PROTECT will raise an exception, however, it is nicely caught on the regular ModelAdmin, but not on inlines.