I can override edit_inline/tabular.html
if I save it in my overall template directory (for example mysite/templates/admin/edit_inline/tabular.html
), but when I try to save it with other admin template, like change_form.html
(in mysite/myapp/templates/admin/myapp/mymodel/change_form.html
, it doesn't works.
I come across this thread which is a bit old, in fact for the inline model you need to explicitly set your new template in your admin.py like below :
class ModelInlineAdmin(admin.StackedInline):
model = Product
template = "admin/products/product/edit_inline/stacked.html"
-
Thank you for the answer, please mind that the link provided is no longer active. – raratiru Sep 10 '17 at 17:34
The documentation hints that inlines can have a template
attribute. Try setting that to admin/myapp/mymodel/edit_inline/tabular.html
and create the corresponding template file in the templates
directory of myapp
.
The form is like this:
templates/admin/app_name/override.html
For you change_form.html example, it should be like this:
mysite/templates/admin/myapp/change_form.html
See http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates for more.