【发布时间】:2015-06-09 17:31:37
【问题描述】:
我通过设置在 settings.py 文件中包含了我的模板文件夹的路径:
TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates')
STATIC_FILES_DIR 也是如此,但我不断收到 TemplateDoesNotExist 错误。当我查看错误的事后分析时,我看到:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
C:\Python27\lib\site-packages\django\contrib\admin\templates\home.html (File does not exist)
C:\Python27\lib\site-packages\django\contrib\auth\templates\home.html (File does not exist)
为什么 template.loader 会在该目录中查找模板文件,而不是在我的 settings.py 文件中指定的文件?此外,当我将home.html 页面复制到错误消息中提到的第一个目录中时,页面加载内容时不会出错,那么如何让加载程序从它正在搜索的位置移动到文件所在的目录实际位于?
【问题讨论】:
标签: python django templates django-templates django-settings