Users will log into our blogging site using their email and password; so, before we begin building our actual login view, let's start with the
LoginForm. This form will accept the
password, and will also present a checkbox to indicate whether the site should
remember me. Create a
forms.py module in the
app directory and add the following code:
import wtforms from wtforms import validators from models import User class LoginForm(wtforms.Form): email = wtforms.StringField("Email", validators=[validators.DataRequired()]) password = wtforms.PasswordField("Password", validators=[validators.DataRequired()]) remember_me = wtforms.BooleanField("Remember me?", default=True)
Note that WTForms also provides an e-mail validator. ...