Django

Code

Ticket #4810 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

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

Reported by: ubernostrum Assigned to: adrian
Milestone: Component: django.contrib.admin
Version: newforms-admin Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

4810.diff (1.3 kB) - added by ubernostrum on 07/09/07 02:36:44.
Patch implementing the check with isinstance() instead of issubclass()

Change History

07/09/07 02:36:44 changed by ubernostrum

  • attachment 4810.diff added.

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

07/09/07 02:37:00 changed by ubernostrum

  • needs_better_patch changed.
  • has_patch set to 1.
  • needs_tests changed.
  • needs_docs changed.

07/09/07 10:50:48 changed by jkocherhans

  • version changed from SVN to newforms-admin.

07/11/07 21:25:42 changed by Simon G. <dev@simon.net.nz>

  • stage changed from Unreviewed to Ready for checkin.

08/24/07 09:27:08 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

(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/Change #4810 ([newforms-admin] Bad check for model classes in AdminSite)




Change Properties
Action