Opened 17 years ago

Closed 17 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: no UI/UX: no

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 17 years ago.
Patch implementing the check with isinstance() instead of issubclass()

Download all attachments as: .zip

Change History (5)

by James Bennett, 17 years ago

Attachment: 4810.diff added

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

comment:1 by James Bennett, 17 years ago

Has patch: set

comment:2 by jkocherhans, 17 years ago

Version: SVNnewforms-admin

comment:3 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedReady for checkin

comment:4 by Russell Keith-Magee, 17 years ago

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