简体   繁体   English

如何将数据从一条路线传输到烧瓶中的另一条路线

[英]how to transfer data from one route to another in flask

I'm having some trouble transferring info from a form from one route (main) to another route (score)我在将表单中的信息从一条路线(主要)传输到另一条路线(得分)时遇到了一些麻烦
this is my main route calling the form这是我调用表单的主要途径

@main.route('/', methods=['GET', 'POST'])
def root():
    form = form()
    if form.validate_on_submit():
        form_data = form.score.data
        return redirect(url_for('main.score', form_data=form_data))
    return render_template('root.html', form=form)

and in the score layout i have this在分数布局中我有这个

{% extends 'layout.html' %}

{% block content %}
    <p>{{ form_data.score }}</p>
{% endblock content %}

i want it to display the score that the user inputs into the form我希望它显示用户输入到表单中的分数
and i keep getting this error:我不断收到此错误:

jinja2.exceptions.UndefinedError: 'form_data' is undefined jinja2.exceptions.UndefinedError: 'form_data' 未定义

您应该只呈现分数模板,而不是尝试重定向到它:

return render_template('score.html', form_data=form_data)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将数据从一个函数传输到另一个函数? - How can I transfer data from one funtction to another? python - 如何使用插入命令将数据从一个SQL服务器传输到另一个SQL服务器? - How to transfer the data from one SQL server to another using insert into command using python? 如何在一个函数中从用户获取插入列表,然后将元组数据传输到另一个函数? - How can I take an inut list from user in one function, and transfer the tuple data to another function? 如何使用 url 参数从一个 flask 应用程序重定向到另一个 flask 应用程序 - How do I redirect from one flask app to another flask app with url parameters 如何从 Ajax 调用向 Flask 提交数据,并在 Flask 中从另一个 Z3EB7106C34177A60E6BBF555 调用返回其响应? - How to submit data to Flask from an Ajax call, and return its response in Flask from another Ajax call? 如何从其他路线 function flask 运行路线? - How to run route from other route function flask? 在烧瓶中从一个应用程序调用变量到另一个应用程序 - calling a variable from one app to another in flask 如何将数据从一列移动到另一列? - How to move data from one column to another? 如何将数据从一个 function 传递到另一个? - How to pass data from one function to another? 将值从一个数字转移到另一个数字最大pythonically - Transfer value from one number to another up to max pythonically
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM