Display link to full change form for object in django admin -
because nested inlines not yet supported, wondering how display link related object alternative. came across question other day link app, can't seem find again.
here looking @ doing:
have manager model contains name, address etc.
i have property model has inlines , related manager model.
i wanting manager model able display link in change form each of properties related it.
is can done?
sure, can overwrite change view. http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.modeladmin.change_view
copy template real admin template directory , place anywhere (since can point @ change_form_template
, , add in stuff display.
i pretty commonly.
class mymodeladmin(admin.modeladmin): change_form_template = 'myapp/new_change_form.html' def change_view(self, request, object_id, extra_context=none): properties = manager.objects.get(id=object_id).property_set.all() extra_context = { 'properties':properties } super(mymodeladmin, self).change_view(request, object_id, extra_context)
find place in admin template add of own html.
<ul> {% property in properties %} <li> <a href="{% url admin:myapp_manager_change property.id %}">edit {{ property }}</a> </li> {% endfor %} </ul>
Comments
Post a Comment