python
config_error
ai_generated
true
模板不存在:myapp/index.html
django.template.exceptions.TemplateDoesNotExist: myapp/index.html
ID: python/django-template-not-found
80%修复率
89%置信度
0证据数
2024-05-25首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
Django无法在模板目录中找到指定的模板文件
English
模板文件路径错误或模板目录未配置
解决方案
-
95% 成功率
mkdir -p myapp/templates/myapp && 将index.html放入
-
90% 成功率
'DIRS': [os.path.join(BASE_DIR, 'templates')]
无效尝试
常见但无效的做法:
-
70% 失败
如果APP_DIRS=False,应用内模板不会被自动搜索
-
80% 失败
Django默认只搜索应用内templates目录