Django:覆盖base_site.html [英] Django: Overrideing base_site.html
问题描述
Folks,
我尝试以下步骤在 Django Tutorial 用于自定义管理模板。我按照步骤到信中,创建一个目录结构如下:
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 site admin更改为我的网站管理员。
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.
然后,我遵循了关于这篇文章的建议/ a>并创建了以下目录结构:
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屋!