Django:覆盖 base_site.html [英] Django: Overrideing base_site.html
问题描述
各位,我尝试按照 Django 教程 中的步骤自定义管理模板.我按照字母的步骤创建了一个目录结构如下:
Folks, I tried following steps in the Django Tutorial for customizing the admin template. I followed the steps to the letter, creating a directory structure as follows:
- myproject/
- myproject/
- templates/
- admin/
- base_site.html
- myapp1/
- manage.py
我编辑了 base_site.html 以将文本Django 站点管理员"更改为我的站点管理员".
I edited base_site.html to change text "Django site admin" to "My site admin".
我编辑了 myproject/settings.py 以添加:
I edited myproject/settings.py to add:
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
运行后,我对 base_site.html 的更改没有生效.
Upon running this, my changes to base_site.html did not take effect.
然后我按照这篇文章上的建议创建了以下目录结构:
I then followed the advise on this post and created the following directory structure:
- myproject/
- myproject/
- templates/
- admin/
- base_site.html
- myapp1/
- manage.py
并将以下内容添加到我的 settings.py 文件中:
And added the following to my settings.py file:
TEMPLATE_DIRS = (os.path.join(BASE_DIR,'..', 'mytemplates'),)
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
当我访问管理页面时,仍然会看到Django 管理".我做错了什么?
I am still greeted by "Django administration" when I visit the admin page. What am I doing wrong?
推荐答案
BASE_DIR 是指基本目录,所以你应该在新布局中使用 TEMPLATE_DIRS 的原始值.
BASE_DIR refers to, well, the base dir, So you should use the original value of TEMPLATE_DIRS with the new layout.
这篇关于Django:覆盖 base_site.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!