如何从包外扩展 base.html?

how to extend base.html from outside of the package?

我需要在我的其他包中扩展 base.html。

我的应用结构

-flask_blog
|-- app_bone
|     |-- __init__.py
|     |-- blog
|     |     |-- __init__.py
|     |     |-- routes.py
|     |     |-- templates
|     |     |     |-- blog
|     |     |     |     |-- blog.html
|-- templates
|     |-- base.html
-run.py

app_bone/blog/route.py

from flask import render_template, Blueprint

blog = Blueprint('blog', __name__, template_folder='templates')


@blog.route('/')
def blog_list():
    return render_template('blog/blog.html')

app_bone/templates/blog/blog.html

{% extends 'base.html' %}

{% block content %}
<h1> blog </h1>
{% endblock %}

我在 运行 烧瓶

时发现了这个错误

jinja2.exceptions.TemplateNotFound: base.html

在 Flask 文档中,您的项目布局应如下所示 https://flask.palletsprojects.com/en/1.0.x/tutorial/layout/ 然后你可以用你的 base.html 文件到达 {% extends 'base.html' %}