簡體   English   中英

燒瓶藍圖自我重定向

[英]Flask Blueprint self redirect

我急於得到一個錯誤:

werkzeug.routing.BuildError:無法為端點'foo.bar,id = 1'構建URL。 您是說“ foo.bar”嗎?

foobp= Blueprint('foo', __name__)

@foobp.route('/bar/<id>', , methods=['get', 'post'])
def bar(id):
    id_var = id
    form = SomeForm()
    if form.validate_on_submit():
        # do database stuff
        return redirect(url_for('foo.bar, id={}'.format(id_var)))
    # do some other stuff
    return render_template('bar'html, form=form, ...)

我嘗試刪除'foo.bar'並僅執行'bar'但這似乎也不起作用。

我究竟做錯了什么?

嘗試這個:

return redirect(url_for('foo.bar', id=id_var))

另外,您的路線定義中有兩個逗號。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM