python config_error ai_generated true

jinja2.exceptions.TemplateNotFound: index.html

ID: python/flask-blueprint-template-not-found

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

Flask blueprint's template folder not set or template file not in expected directory.

generic

中文

Flask 蓝图的模板文件夹未设置或模板文件不在预期目录中。

Workarounds

  1. 95% success
    Set template_folder in Blueprint: bp = Blueprint('bp', __name__, template_folder='templates')
    # Ensure templates/index.html exists in blueprint package
  2. 85% success
    Use app.add_template_folder to add additional template directories

Dead Ends

Common approaches that don't work:

  1. 60% fail

    Blueprint defaults to app's template folder unless overridden.

  2. 80% fail

    render_template expects relative path to template folder.