سؤال

I'm trying to extend django's admin change_form.html (django/contrib/admin/templates/admin/change_form.html).

What makes this more complicated for me is that I've installed grappelli, which also extends it (grappelli/templates/admin/change_form.html)

Now, I want to change it in myproject (to apply for all apps/modules in my project), and have tried to place change_form in various places but to no avail:

  • myproject/templates/admin/change_form.html
  • myproject/templates/grappelli/change_form.html
  • myproject/templates/admin/grappelli/change_form.html

Does anyone have a clue about where I should be placing my modified version of change_form.html in order for django to actually use it?

(any help on understanding django's search path & template extension mechanism will be appreciated).

Thanks!

هل كانت مفيدة؟

المحلول

You can include your template directory to TEMPLATE_DIRS

TEMPLATE_DIRS = (
     os.path.join(BASE_DIR, 'myapp/templates/'),
)

This way you can change the order in which Django reads your template files.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top