python
config_error
ai_generated
true
django.template.exceptions.TemplateDoesNotExist: myapp/index.html
ID: python/django-template-not-found
80%Fix Rate
89%Confidence
0Evidence
2024-05-25First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
模板文件路径错误或模板目录未配置
generic中文
Django无法在模板目录中找到指定的模板文件
Workarounds
-
95% success
mkdir -p myapp/templates/myapp && 将index.html放入
-
90% success
'DIRS': [os.path.join(BASE_DIR, 'templates')]
Dead Ends
Common approaches that don't work:
-
70% fail
如果APP_DIRS=False,应用内模板不会被自动搜索
-
80% fail
Django默认只搜索应用内templates目录