python config_error ai_generated true

模板不存在错误:base.html

django.template.exceptions.TemplateDoesNotExist: base.html

ID: python/django-template-inheritance-error

其他格式: JSON · Markdown 中文 · English
80%修复率
85%置信度
0证据数
2025-09-10首次发现

版本兼容性

版本状态引入弃用备注
3.x active

根因分析

基础模板文件缺失或不在模板目录中。

English

The base template file is missing or not in the template directories.

generic

解决方案

  1. 95% 成功率
    Ensure base.html exists in templates directory and set TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [BASE_DIR/'templates']}]
  2. 90% 成功率
    Use {% extends 'app/base.html' %} and ensure app/templates/app/base.html exists.

无效尝试

常见但无效的做法:

  1. 60% 失败

    Setting TEMPLATE_DIRS incorrectly doesn't find the template.

  2. 40% 失败

    Using absolute path without adding to DIRS still fails.