[英]Django can't find location to load templates/css from
我通過設置將我的模板文件夾的路徑包括在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
頁面復制到錯誤消息中提到的第一個目錄中時,該頁面將加載內容而不會出現錯誤,因此如何使加載程序從搜索位置移動到文件所在的目錄實際位於?
有效設置名稱為TEMPLATE_DIRS
,它是字符串的元組,而不是簡單的字符串:
TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates'), )
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.