Flask-WTF

Other topics

A simple Form

from flask_wtf import FlaskForm
from wtforms import StringField, IntegerField
from wtforms.validators import DataRequired

class MyForm(FlaskForm):
    name = StringField('name', validators=[DataRequired()])
    age = InterField('age', validators=[DataRequired()])

To render the template you will use something like this:

<form method="POST" action="/">
    {{ form.hidden_tag() }}
    {{ form.name.label }} {{ form.name(size=20) }}
    <br/>
    {{ form.age.label }} {{ form.age(size=3) }}
    <input type="submit" value="Go">
</form>

The above simple code will generate our very simple flask-wtf web form with a hidden CRSF token field.

Contributors

Topic Id: 10579

Example Ids: 31761

This site is not affiliated with any of the contributors.