python
config_error
ai_generated
true
Jinja2 异常:未找到模板 index.html。
jinja2.exceptions.TemplateNotFound: index.html
ID: python/flask-blueprint-template-not-found
80%修复率
86%置信度
0证据数
2024-04-02首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
Flask 蓝图的模板文件夹未设置或模板文件不在预期目录中。
English
Flask blueprint's template folder not set or template file not in expected directory.
解决方案
-
95% 成功率
Set template_folder in Blueprint: bp = Blueprint('bp', __name__, template_folder='templates') # Ensure templates/index.html exists in blueprint package -
85% 成功率
Use app.add_template_folder to add additional template directories
无效尝试
常见但无效的做法:
-
60% 失败
Blueprint defaults to app's template folder unless overridden.
-
80% 失败
render_template expects relative path to template folder.