Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#16917 closed Bug (fixed)

Listing leftover content types for missing models breaks admin

Reported by: Ivan Sagalaev Owned by: Ivan Sagalaev
Component: contrib.contenttypes Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


If during the lifecycle of the project some models got removed and their registered content types still remain in the DB the admin (or any such code for that matter) crashes trying to display content types. This happens due to ContenType.__unicode__ relying on self.model_class() to be always available. This is a recent regression from [16839].

Attachments (1)

16917.diff (1.6 KB) - added by Ivan Sagalaev 7 years ago.

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by Ivan Sagalaev

Attachment: 16917.diff added


comment:1 Changed 7 years ago by Ivan Sagalaev

Has patch: set

comment:2 Changed 7 years ago by Carl Meyer

Triage Stage: UnreviewedReady for checkin

Thanks for catching this. Makes the idea of eventually deprecating the "name" field slightly trickier, though I guess we could still put together a reasonable unicode representation from the other fields. Doesn't matter too much what the unicode representation for a stale content type is.

comment:3 Changed 7 years ago by Ivan Sagalaev

Oh, I think anything like "(missing)" or even "---" will work. I used only because right now it's a little bit more informative.

comment:4 Changed 7 years ago by Carl Meyer

Resolution: fixed
Status: newclosed

In [16895]:

Fixed #16917 -- Don't try to use the model name for a ContentType's unicode representation if the model no longer exists. Thanks Ivan Sagalaev for report and patch.

comment:5 Changed 7 years ago by Ivan Sagalaev

Thanks for a lightning fast commit, Carl!

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