0
/CSS我包括路徑在settings.py文件我的模板文件夾設置:Django中找不到位置加載模板從
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
頁面複製到錯誤消息中提到的第一個目錄中時,該頁面無錯誤地加載內容,那麼如何讓加載程序從搜索的位置移動到文件所在的目錄位於?
注爲未來的用戶:此設置有利於['TEMPLATES'(HTTPS的棄用:// docs.djangoproject.com/en/1.8/ref/templates/upgrading/#the-templates-settings)從Django 1.8開始。 – Selcuk 2015-04-04 23:07:10
是否有另一種可能的解釋?即使進行此更改,錯誤仍然存在。 – 2015-04-04 23:17:30
@Selcuk是的,你說得對。但設置stilll複數'DIRS'和元組類型:-) – catavaran 2015-04-05 02:03:47