Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#17140 closed Bug (duplicate)

Unexpected behaviour with on_delete handlers and proxy models (IntegrityError)

Reported by: Jaap Roes Owned by: nobody
Component: Database layer (models, ORM) Version: 1.3
Severity: Normal Keywords: ForeignKey on_delete proxy model IntegrityError CASCADE SET_NULL
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Let's say I have a File model and an Image model. The second one being a proxy to the File model, with some additional methods and a manager that only return image-like files.

Another model has a ForeignKey to the Image model. Deleting an Image will trigger the on_delete handlers of it's foreign keys, cascades happen and everything is fine.

Deleting the same thing as an instance of File however will not clean up every objects linking to it. Instead an IntegrityError is raised. It's obvious that the File doesn't know it's also an Image and therefore doesn't trigger the on_delete handler of foreign keys referring to it by a different name.

I don't really see a nice way to work around or fix this problem.

Attachments (1) (1.7 KB ) - added by Jaap Roes 12 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 by Jaap Roes, 12 years ago

This seems related (but in reverse) to ticket #16128

comment:2 by Carl Meyer, 12 years ago

Triage Stage: UnreviewedAccepted

by Jaap Roes, 12 years ago

Attachment: added


comment:3 by Carl Meyer, 12 years ago

Resolution: duplicate
Status: newclosed

I'm not sure I see how this is the reverse of #16128. If I'm reading that one right, the failure is in the exact same case: FK pointing to proxy model, real parent of proxy deleted. I think this is a duplicate of that ticket.

comment:4 by Jaap Roes, 12 years ago

Yes, it seems to be a duplicate. I think I got confused after reading the comments and the patches of the other ticket.

I've expended my testcases to include the proxy of proxy case, and will attach it to the other bug. Thanks!

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