python
config_error
ai_generated
true
模板不存在错误:base.html
django.template.exceptions.TemplateDoesNotExist: base.html
ID: python/django-template-inheritance-error
80%修复率
85%置信度
0证据数
2025-09-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
基础模板文件缺失或不在模板目录中。
English
The base template file is missing or not in the template directories.
解决方案
-
95% 成功率
Ensure base.html exists in templates directory and set TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [BASE_DIR/'templates']}] -
90% 成功率
Use {% extends 'app/base.html' %} and ensure app/templates/app/base.html exists.
无效尝试
常见但无效的做法:
-
60% 失败
Setting TEMPLATE_DIRS incorrectly doesn't find the template.
-
40% 失败
Using absolute path without adding to DIRS still fails.