python
config_error
ai_generated
true
模板不存在:admin/login.html
django.template.exceptions.TemplateDoesNotExist: admin/login.html
ID: python/django-template-loader-error
80%修复率
86%置信度
0证据数
2024-12-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.2 | active | — | — | — |
| 4.0 | active | — | — | — |
| 5.0 | active | — | — | — |
根因分析
模板文件路径错误或模板目录未正确配置
English
Django 在模板目录中找不到指定的模板文件
解决方案
-
95% 成功率 检查模板路径是否正确
确保模板文件位于 app/templates/admin/login.html 或 DIRS 指定的目录
-
90% 成功率 在 settings.py 中配置模板目录
TEMPLATES[0]['DIRS'] = [BASE_DIR / 'templates']
无效尝试
常见但无效的做法:
-
在模板目录中创建空文件
90% 失败
空文件会导致渲染错误
-
修改 TEMPLATES 设置中的 DIRS 为错误路径
80% 失败
路径错误仍然找不到模板