Opened 9 years ago

Closed 9 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 9 years ago.

Download all attachments as: .zip

Change History (5)

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

Attachment: model_meta_admin.patch added

comment:1 Changed 9 years ago by anonymous

Has patch: set
Summary: Fixed a bug: attribute `model._meta.admin` is not assigned but it is needed in many places.newforms-admin: Fixed a bug: attribute `model._meta.admin` is not assigned but it is needed in many places.

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

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

comment:3 Changed 9 years ago by jkocherhans

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

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 9 years ago by jkocherhans

Resolution: fixed
Status: newclosed

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.

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