I would like to add a link to /
to every page in template. Can I do it without changing django internal template? I could customize django, but this is something I seriously wouldn't like to do.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Sure, just override one of the Django admin templates in your own templates/admin
directory. For instance, copy the contents of django/contrib/admin/templates/base.html
into yourproject/templates/admin/base.html
. Then, change the latter to your heart's content.
See: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates
回答2:
According to the accepted answer, I still failed to make it. After some try-error experiments, my answer is:
copy
django/contrib/admin/templates/base_site.html
to asyour_project/templates/admin/base_site.html
customize your local
base_site.html
to whatever you wantadd to your settings.py
TEMPLATE_DIRS = ('templates',)