I'm retrieving a model using django.db.models.get_model. The view is receiving a post from a form generated by the ModelAdmin. How can I get a hold of that ModelAdmin instance so can then get a hold of the ModelForm? This will allow me to process the post (validation, related objects, etc). The ModelAdmin has a reference to it's model, but the reverse doesn't seem to be true.
The way I'm doing this right now is bad juju. The AdminSite keeps a registry of models and ModelAdmins so I'm doing this: modeladmin = admin.site._registry[model]; Obviously using this internal registry is a bad idea. I was looking for a more official api similar to get_model or one of the following: modeladmin = admin.site.get_admin(model) Even if this just returns the instance from the registry like above. Or make it accessible through the model like one of the following: modeladmin = model.get_admin() modeladmin = model._admin Any help with this is appreciated Now a litlte more context. Like I mentioned above, what I actually need is a ModelForm similar to the one generated by the admin site. I have a custom admin view that receives the post from an add/change form. So to process that post I need the equivalent ModelForm. If there is an easier or more idiomatic way to write custom admin views, I'd appreciate if someone pointed me in the right direction.
-- 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.