Code

Opened 7 years ago

Closed 7 years ago

#4810 closed (fixed)

[newforms-admin] Bad check for model classes in AdminSite

Reported by: ubernostrum Owned by: adrian
Component: contrib.admin Version: newforms-admin
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

AdminSite.register and AdminSite.unregister both are meant to accept either a model class or a list of model classes, and differentiate the two by checking issubclass(model_or_iterable, Model), but this will blow up on a list -- the first argument to issubclass must be a class.

One alternative might be to import django.db.models.base.ModelBase and use isinstance(model_or_iterable, ModelBase).

Attachments (1)

4810.diff (1.3 KB) - added by ubernostrum 7 years ago.
Patch implementing the check with isinstance() instead of issubclass()

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by ubernostrum

Patch implementing the check with isinstance() instead of issubclass()

comment:1 Changed 7 years ago by ubernostrum

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

comment:2 Changed 7 years ago by jkocherhans

  • Version changed from SVN to newforms-admin

comment:3 Changed 7 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:4 Changed 7 years ago by russellm

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

(In [6000]) newforms-admin: Fixed #4810, Refs #4571 -- Reversed the logic for the type check introduced in [5999]; this way should be a little more robust from an error handling point of view. Thanks to ubernostrum for the suggestion. Oh, and Changeset 6000!! w00t!!

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.