'type(v)' is model..instead of 'v is model' works,
in case not too late for someone else...
thanks Matt..
def get_admin(model):
for k,v in admin.site._registry.iteritems():
if type(v) is model:
return v
On Monday, January 11, 2010 at 9:37:47 PM UTC, Matt Schinckel
I'm currently using the site._registry approach. I was hoping there
was either a more "official" way.
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
On Jan 12, 4:11 am, Tomasz Zieliński
wrote:
> On 11 Sty, 16:23, Marco Rogers wrote:
>
> > I'm reposting this from earlier to see if I have better luck. I need
> > to be able to get the ModelAdmin associated with a model at runtime.
> >
On 11 Sty, 16:23, Marco Rogers wrote:
> I'm reposting this from earlier to see if I have better luck. I need
> to be able to get the ModelAdmin associated with a model at runtime.
> Similar to how django.db.models.get_model allows you to retrieve a
> model.
>
>
I'm reposting this from earlier to see if I have better luck. I need
to be able to get the ModelAdmin associated with a model at runtime.
Similar to how django.db.models.get_model allows you to retrieve a
model.
admin_class = get_admin(Model)
Is this possible?
The original post has more
5 matches
Mail list logo