Opened 13 years ago

Closed 13 years ago

Last modified 13 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

Description

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 13 years ago.
Patch

Download all attachments as: .zip

Change History (6)

by Ivan Sagalaev, 13 years ago

Attachment: 16917.diff added

Patch

comment:1 by Ivan Sagalaev, 13 years ago

Has patch: set

comment:2 by Carl Meyer, 13 years ago

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 by Ivan Sagalaev, 13 years ago

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

comment:4 by Carl Meyer, 13 years ago

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 by Ivan Sagalaev, 13 years ago

Thanks for a lightning fast commit, Carl!

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