On 11 Sty, 16:23, Marco Rogers <marco.rog...@gmail.com> 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.
>
>     admin_class = get_admin(Model)
>
> Is this possible?
>
> The original post has more info.
>
> http://groups.google.com/group/django-users/browse_thread/thread/0cd0...

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 received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to