TemplateDoesNotExist
如題,照著Django官網的範例操作練習,測試template的效果
操作網頁上"Write views that actually do something"的大項中
結果遇到了這個問題,看起來它都會到非預期的地方撈取html
中英文的網頁都看了,找不到問題在哪
https://docs.djangoproject.com/en/2.1/intro/tutorial03/
簡稱說明如下
[VirtualEnv]: 建立虛擬環境的資料夾
[DjangoProj]: 放Django專案的資料夾
錯誤訊息如下
django.template.loaders.app_directories.Loader:
[VirtualEnv]\lib\site-packages\django\contrib\admin\templates\
polls\template\polls\index.html (Source does not exist)
django.template.loaders.app_directories.Loader:
[VirtualEnv]\lib\site-packages\django\contrib\auth\templates\
polls\template\polls\index.html (Source does not exist)
我的專案和虛擬環境習慣分開放(或是說這是不好的習慣?)
依我對官網上說明文件的理解,它應該要到[DjangoProj]\mysite\polls\template\polls
這個資料夾去找index.html
為什麼它會跑到上述的兩個錯的資料夾找呢?
手動把index.html放到上面兩個錯的資料夾的其中之一下,就能如預期顯示結果
或是在setting.py內的 TEMPLATES 補上
'DIRS': ['polls/template']
結果才會正常,請問是為什麼?
('APP_DIRS': 預設是True)
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.192.89.192
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1553075402.A.102.html
→
03/20 19:23,
5年前
, 1F
03/20 19:23, 1F
→
03/20 21:02,
5年前
, 2F
03/20 21:02, 2F
推
03/22 18:34,
5年前
, 3F
03/22 18:34, 3F
→
03/22 18:34,
5年前
, 4F
03/22 18:34, 4F
→
03/22 18:35,
5年前
, 5F
03/22 18:35, 5F
→
03/26 16:48,
5年前
, 6F
03/26 16:48, 6F