从WTForms表单获取数据 [英] Get data from WTForms form
本文介绍了从WTForms表单获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
提交后如何从WTForms表单中获取数据?我想在表格中输入电子邮件.
How do I get the data from a WTForms form after submitting it? I want to get the email entered in the form.
class ApplicationForm(Form):
email = StringField()
@app.route('/', methods=['GET', 'POST'])
def index():
form = ApplicationForm()
if form.validate_on_submit():
return redirect('index')
return render_template('index.html', form=form)
<form enctype="multipart/form-data" method="post">
{{ form.csrf_token }}
{{ form.email }}
<input type=submit>
</form>
推荐答案
Each field has a data
attribute containing the processed data.
the_email = form.email.data
在 查看全文