Code

Opened 7 years ago

Closed 7 years ago

#4587 closed (fixed)

[newforms-admin] attribute `model._meta.admin` is not assigned but it is needed in many places.

Reported by: yi.codeplayer at gmail dot com Owned by: nobody
Component: contrib.admin Version: newforms-admin
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

Description

This patch is quiet simple, just set attribute model._meta.admin = admin_class before register the model.

PS: I've submit a ticket before, which fixed several bugs in newforms-admin branch including this one, but i don't see it fixed so far, so i decide to seperate this one out.

Attachments (1)

model_meta_admin.patch (564 bytes) - added by yi.codeplayer at gmail dot com 7 years ago.

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by yi.codeplayer at gmail dot com

comment:1 Changed 7 years ago by anonymous

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Fixed a bug: attribute `model._meta.admin` is not assigned but it is needed in many places. to newforms-admin: Fixed a bug: attribute `model._meta.admin` is not assigned but it is needed in many places.

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

  • Summary changed from newforms-admin: Fixed a bug: attribute `model._meta.admin` is not assigned but it is needed in many places. to [newforms-admin] attribute `model._meta.admin` is not assigned but it is needed in many places.
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:3 Changed 7 years ago by jkocherhans

  • Patch needs improvement set
  • Triage Stage changed from Ready for checkin to Accepted

This is not going to work if you have multiple AdminSite instances. The best way to fix this is to replace any calls to model._meta.admin with code that looks something up from the current AdminSite's registry. "current" only has meaning in view code, however.

The adminindex command in particular uses model._meta.admin and would really have no concept of what the "current" AdminSite is (unless you always assumed it uses the default one.) We could give each AdminSite object a unique name and let adminindex take that name as an optional argument (no argument means use the default one), or drop the adminindex command all together.

comment:4 Changed 7 years ago by jkocherhans

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

Ticket #5500 covers the last case where model._meta.admin is being used in the code. Please open new tickets if there are any more examples where _meta.admin is used in Django.

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.