Opened 7 years ago

Closed 7 years ago

#11821 closed (duplicate)

Objects with multiple foreign key relationships to the same table will not correctly warn about deletion of related objects

Reported by: shields@… Owned by: nobody
Component: contrib.admin Version: 1.1
Severity: Keywords:
Cc: mshields@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Consider:

class Thing(models.Model):
    foreground_color = models.ForeignKey(Color, related_name='thing_foreground')
    background_color = models.ForeignKey(Color, related_name='thing_background')

The admin delete view for a Color will correctly warn about the cascade deletions of all Things with that foreground_color. However, it will not show the deletions of Things with that background_color, and they will be deleted. This is surprising and dangerous behavior.

A patch and regression test are included.

Attachments (1)

multiple-fk-delete-view.txt (4.1 KB) - added by shields@… 7 years ago.

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by shields@…

Attachment: multiple-fk-delete-view.txt added

comment:1 Changed 7 years ago by anonymous

Component: Uncategorizeddjango.contrib.admin
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 7 years ago by Karen Tracey

Resolution: duplicate
Status: newclosed

This is a dupe of #6191. You might want to attach your patch there, with a .diff extension so that it will hopefully display nicely in trac.

Note: See TracTickets for help on using tickets.
Back to Top