python config_error ai_generated true

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

ID: python/django-template-not-found

Also available as: JSON · Markdown · 中文
80%Fix Rate
89%Confidence
0Evidence
2024-05-25First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

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

generic

中文

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

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 70% fail

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

  2. 80% fail

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