python config_error ai_generated true

模板不存在:myapp/index.html

django.template.exceptions.TemplateDoesNotExist: myapp/index.html

ID: python/django-template-not-found

其他格式: JSON · Markdown 中文 · English
80%修复率
89%置信度
0证据数
2024-05-25首次发现

版本兼容性

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

根因分析

Django无法在模板目录中找到指定的模板文件

English

模板文件路径错误或模板目录未配置

generic

解决方案

  1. 95% 成功率
    mkdir -p myapp/templates/myapp && 将index.html放入
  2. 90% 成功率
    'DIRS': [os.path.join(BASE_DIR, 'templates')]

无效尝试

常见但无效的做法:

  1. 70% 失败

    如果APP_DIRS=False,应用内模板不会被自动搜索

  2. 80% 失败

    Django默认只搜索应用内templates目录