July 2018
Intermediate to advanced
324 pages
8h 14m
English
Flask-WTF extensions provide the ability to develop forms in Flask and render them through Jinja2 templates. Flask-WTF extends the WTForms library, which has standard patterns to design a form.
We need two forms for this, such as SignupForm and LoginForm. The following is the code for creating forms classes.
File—auth/forms.py:
from flask_wtf import FlaskFormfrom wtforms import StringField, PasswordField, SubmitFieldfrom wtforms.validators import Required, Length, Email, EqualToclass LoginForm(FlaskForm): email = StringField( 'Email', validators=[Required(), Length(1,64), Email()] ) password = PasswordField( 'Password', validators=[Required()] ) submit = SubmitField('Log In')class SignupForm(FlaskForm): email = StringField( 'Email', ...Read now
Unlock full access