Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#12760 closed (duplicate)

related models with Foreignkey.null=True must not get deleted on delete of their relation

Reported by: defaultwombat Owned by: nobody
Component: Database layer (models, ORM) Version: 1.1
Severity: Keywords: delete foreignkey null
Cc: kanu@…, plandry@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The "delete related objects" process appears bugged to me.
In some lines of the code it looks like the intention was to set foreignkeys of related objects to null if possible, instead of deleting the object. Nevertheless the deletion does happen.

This is only about Realtions with Foreignkey(..,null=True). Other relations work as intended.

Problem 1:

Related Objects get deleted during delete_objects()

Problem 2:

Subrelation of related objects get collected during _collect_sub_objects()

Please have a look at the test file.

Attachments (1) (6.4 KB) - added by defaultwombat 10 years ago.
Testfile with 2 Models

Download all attachments as: .zip

Change History (3)

Changed 10 years ago by defaultwombat

Attachment: added

Testfile with 2 Models

comment:1 Changed 10 years ago by Luke Plant

Resolution: duplicate
Status: newclosed

Duplicate of #10262, #7539

comment:2 Changed 10 years ago by anonymous

Cc: plandry@… added
Note: See TracTickets for help on using tickets.
Back to Top