从 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>
推荐答案
每个字段都有一个data
包含处理数据的属性.
Each field has a data
attribute containing the processed data.
the_email = form.email.data
入门文档.
这篇关于从 WTForms 表单中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文