python config_error ai_generated true

django.template.exceptions.TemplateDoesNotExist: admin/login.html

ID: python/django-template-loader-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
0Evidence
2024-12-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.2 active
4.0 active
5.0 active

Root Cause

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

generic

中文

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

Workarounds

  1. 95% success 检查模板路径是否正确
    确保模板文件位于 app/templates/admin/login.html 或 DIRS 指定的目录
  2. 90% success 在 settings.py 中配置模板目录
    TEMPLATES[0]['DIRS'] = [BASE_DIR / 'templates']

Dead Ends

Common approaches that don't work:

  1. 在模板目录中创建空文件 90% fail

    空文件会导致渲染错误

  2. 修改 TEMPLATES 设置中的 DIRS 为错误路径 80% fail

    路径错误仍然找不到模板