richard0096 richard0096 - 9 months ago 44
Python Question

Get data from WTForms form

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 }}
{{ }}
<input type=submit>

Answer Source

Each field has a data attribute containing the processed data.

the_email =

Working with form data is described in the getting started doc.