admin_class = get_admin(Model)
Is this possible?
The original post has more info.
http://groups.google.com/group/django-users/browse_thread/thread/0cd08f966eae8ee2#
Maybe something like this:
1. Write something like django.contrib.admin.autodiscover, to get all
ModelAdmins
2. Iterate those ModelAdmins, retrieve models they are attached to and
store this mapping in a dict.
3. def get_admin(model):
return admin_to_model[model]
?
--
Tomasz Zielinski
http://pyconsultant.eu
You should be able to iterate through admin.site._registry, and pull
out the one you need.
from django.contrib import admin
def get_admin(model):
for k,v in admin.site._registry.iteritems():
if v is model:
return v
Written in a browser.
Matt.
Incidentally, the registry is a dict so you should be able to access
the model directly.
from django.contrib import admin
def get_admin(model):
if model in admin.site._registry
return admin.site._registry[model]
return None
I haven't testing this because I'm doing something slightly different
:Marco
On Jan 11, 4:37 pm, Matt Schinckel <matt.schinc...@gmail.com> wrote:
> On Jan 12, 4:11 am, Tomasz Zieliñski
if type(v) is model:
return v