烧瓶蓝图不起作用
Flask Blueprint not working
我有一个奇怪的情况,不知道如何找到问题。
我创建了一个这样的蓝图
reportjobsmod = Blueprint('jobreports', __name__, url_prefix='/jobreports', template_folder='templates')
并且我在 views.py
文件
中创建了如下所示的路由
@reportjobsmod.route('/crc_booksdue/', methods=['GET','POST'])
def crc_booksdue():
然后我用
action="{{ url_for('jobreports.crc_booksdue') }}"
在模板中。
这一切都适用于更多路线。
但是,当我尝试将以下路线添加到我的 views.py
@reportjobsmod.route('/job_status/', methods=['GET','POST'])
def jobs_status():
并输入
action="{{ url_for('jobreports.job_status') }}"
在模板中我得到 routing.BuildError
我尝试更改路线名称,我将其替换为现有路线(在模板中工作正常)
我打印了 app.url_map 并且 jobreports.job_status 和其他路线一起在那里。
接下来我该尝试什么?
查看 url_for
文档:
Generates a URL to the given endpoint with the method provided.
这是您应用中的方法,正如应用中拼写的那样。
你的错误来自
The url_for function results in a BuildError when the current app does not have a URL for the given endpoint and values.
函数状态的endpoint
参数
endpoint – the endpoint of the URL (name of the function)
在quickstart里面还有一句:
To build a URL to a specific function you can use the url_for() function. It accepts the name of the function as first argument [...]
我有一个奇怪的情况,不知道如何找到问题。
我创建了一个这样的蓝图
reportjobsmod = Blueprint('jobreports', __name__, url_prefix='/jobreports', template_folder='templates')
并且我在 views.py
文件
@reportjobsmod.route('/crc_booksdue/', methods=['GET','POST'])
def crc_booksdue():
然后我用
action="{{ url_for('jobreports.crc_booksdue') }}"
在模板中。
这一切都适用于更多路线。
但是,当我尝试将以下路线添加到我的 views.py
@reportjobsmod.route('/job_status/', methods=['GET','POST'])
def jobs_status():
并输入
action="{{ url_for('jobreports.job_status') }}"
在模板中我得到 routing.BuildError
我尝试更改路线名称,我将其替换为现有路线(在模板中工作正常)
我打印了 app.url_map 并且 jobreports.job_status 和其他路线一起在那里。
接下来我该尝试什么?
查看 url_for
文档:
Generates a URL to the given endpoint with the method provided.
这是您应用中的方法,正如应用中拼写的那样。
你的错误来自
The url_for function results in a BuildError when the current app does not have a URL for the given endpoint and values.
函数状态的endpoint
参数
endpoint – the endpoint of the URL (name of the function)
在quickstart里面还有一句:
To build a URL to a specific function you can use the url_for() function. It accepts the name of the function as first argument [...]