How to access model class for a ModelAdmin?

449 views
Skip to first unread message

Lee

unread,
Oct 18, 2011, 4:12:19 PM10/18/11
to Django users
This must be easy but I'm not finding it in the docs. I need to access
the model class corresponding to the current ModelAdmin instance, so
that I can iterate through its objects. I need to do this generically
so that I can use the routine in all ModelAdmins.

Thanks for any help.

Lee

Matt Schinckel

unread,
Oct 18, 2011, 11:03:01 PM10/18/11
to django...@googlegroups.com
If you are in an instance method of a ModelAdmin, you can use `self.model` to get the model associated with the ModelAdmin.

Have a look in django.contrib.admin's source for what methods you can override, or hook into.
Reply all
Reply to author
Forward
0 new messages