Form is never valid with WTForms

Flask-WTF adds a CSRF protection field. If it’s not present, the CSRF validation will fail, and the form will be invalid. Use form.hidden_tag() to include any hidden fields in your form (including the CSRF field). <form method=”post”> {{ form.hidden_tag() }} … In general, if a form is not validating, you should check form.errors after calling … Read more

Multiple forms in a single page using flask and WTForms

The solution above have a validation bug, when one form cause a validation error, both forms display an error message. I change the order of if to solve this problem. First, define your multiple SubmitField with different names, like this: class Form1(Form): name = StringField(‘name’) submit1 = SubmitField(‘submit’) class Form2(Form): name = StringField(‘name’) submit2 = … Read more