Opened 9 years ago

Closed 9 years ago

#4810 closed (fixed)

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

Reported by: James Bennett Owned by: Adrian Holovaty
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 James Bennett 9 years ago.
Patch implementing the check with isinstance() instead of issubclass()

Download all attachments as: .zip

Change History (5)

Changed 9 years ago by James Bennett

Attachment: 4810.diff added

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

comment:1 Changed 9 years ago by James Bennett

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

comment:2 Changed 9 years ago by jkocherhans

Version: SVNnewforms-admin

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

Triage Stage: UnreviewedReady for checkin

comment:4 Changed 9 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(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!!

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