【发布时间】:2021-12-20 09:10:07
【问题描述】:
我有以下路线
@app.route("/dashboard/survey/<int:survey_id>/responses", methods=["GET"])
def responses(survey_id):
responses = db.session.query(Survey, Responses).join(Responses).filter(Survey.id == survey_id).filter(
Responses.lan_code == "en").all()
return render_template('responses.html', responses=responses, kws=kws)
@app.route("/dashboard/survey/<int:survey_id>/responses/delete/<int:r_id>/<participant_folder>", methods=["POST"])
def delete_response(survey_id, r_id, participant_folder):
#response = Responses.query.get_or_404(r_id)
#db.session.delete(response)
#db.session.commit()
#pfolder = participant_folder.replace("-", "/")
#print(pfolder)
#shutil.rmtree('qdas/static/audioResponses/' + pfolder, ignore_errors=True)
return redirect(url_for('responses', survey_id))
当我尝试重定向到“响应”时,我收到以下错误:
TypeError: url_for() 接受 1 个位置参数,但给出了 2 个
如果从参数中删除survey_id,我会收到此错误:
werkzeug.routing.BuildError:无法为端点“响应”构建 url。您是否忘记指定值 ['survey_id']?
有没有办法解决这个问题?
【问题讨论】:
标签: flask flask-restful werkzeug url-for