Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#16917 closed Bug (fixed)

Listing leftover content types for missing models breaks admin

Reported by: isagalaev Owned by: isagalaev
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 isagalaev 4 years ago.

Download all attachments as: .zip

Change History (6)

Changed 4 years ago by isagalaev


comment:1 Changed 4 years ago by isagalaev

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 4 years ago by carljm

  • Triage Stage changed from Unreviewed to Ready 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 4 years ago by isagalaev

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 4 years ago by carljm

  • Resolution set to fixed
  • Status changed from new to closed

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 4 years ago by isagalaev

Thanks for a lightning fast commit, Carl!

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