I want to make a registration form using flask_wft but this line never executed
if request.method == 'POST' and form.validate():
because form.validate()
return False
the reason is csrf_token
.
this is my code:
`@app.route('/', methods=['GET', 'POST'])
def form():
form = RegistrationForm(request.form)
if request.method == 'POST' and form.validate():
user = Person(f_name=form.firstName.data,
l_name=form.lastName.data,
email=form.email.data,city=form.city.data)
db.session.add(user)
db.session.commit()
return redirect(url_for('welcome'))
print('errors: '+ str(form.errors))
return render_template('form.html', form=form)`
I got this error: 'csrf_token': ['The CSRF token is missing.']
How to solve the problem?