Foreword, I am one of the authors and currently the main developer of WTForms
Before moving on to the question of why I should mention a very common template for people using WTForms, is to create your own module, which is all the bits you need in one namespace.
For example, in myapp/forms.py you do something like:
from wtforms.fields import * from wtforms import widgets, Form as _Form from wtforms.fields.html5 import EmailField, class Form(_Form): """Awesome base form for myapp. Includes CSRF by default""" class Meta: csrf = True csrf_secret = 'secretpasswordhere' @property def csrf_context(self): return get_current_request().session
You can use the above:
from myapp.forms import Form, TextField, EmailField, ... class UserForm(Form): name = TextField(...) email = EmailField(...)
or alternately with asterisk imports, for example from myapp.forms import *
You will notice that I also included a subclass of custom forms that sets up CSRF and provides a default CSRF context, which is not absolutely necessary. (By the way, Flask-WTF does a similar CSRF setup for you if you use a jar, but the point is to show how you can easily come with your own integration.)
Now why.
The main idea of ββWTForms was to create a very simple and reliable structure that is well suited for most use cases, but extensible enough for people to provide related tools for working with specific use cases.
At the beginning of this decision was to include extensions to interact with various libraries. But this posed a problem in that it significantly increased the complexity and surface area of ββthe test, and also led to the release of WTForms in odd ways (Django just changed this thing, now you need to release new WTForms). Thus, in 2015, we decided to transfer all the extensions to our own packages in order to provide them with their own release schedule.
Instead of forcing people to use a single package that tries to do everything, it led to the creation of a truly large ecosystem with solid companion packages such as Flask-WTF , WTForms-Alchemy and WTForms-Django to name a few.
As to why HTML5 types are not documented; well, this is an omission. Also, some history: at some point, we switched the default output of WTForms from the output from the XHTML style to the HTML syntax; but kept the main outputs of the field. Thus, we got people who contributed to the return of XHTML forms, people contributing html5 fields, and people who wanted to use the default fields used HTML5 types, all after we guaranteed backward compatibility in the main version, which made our a hand.
I know that the long answer, and maybe the short way, is to say this: although WTForms usually works with most web frameworks, it is intended to be configured and customized for your purposes; do not connect and do not play for everything.