WTForms (https://github.com/wtforms/wtforms) is a standalone robust form handling library that allows you to generate HTML forms from form-like classes, implement fields and form validation, and include cross-source forgery protection (a nasty vulnerability that crackers may try to exploit in your Web applications). We certainly don't want that!
First, to install WTForms library, use the following:
pip install wtforms
Now let's write some forms. A WTForms form is a class that extends the
Form class. As plain as that! Let's create a login form that could be used with our previous login example:
from wtforms import Form, StringField, PasswordField class LoginForm(Form): username = StringField(u'Username:') passwd = PasswordField(u'Password:') ...