Wtforms Sqlalchemy
WTForms-SQLAlchemy provides SQLAlchemy integration for WTForms form generation and query fields. It bridges ORM models with form handling in Python web applications. The library offers QuerySelectField, QuerySelectMultipleField, and model_form() for automatic form creation from SQLAlchemy models. Developers use it to simplify database-driven form workflows in Flask and other frameworks. This fork maintains compatibility after WTForms deprecated its ext packages. It is open source and hosted on Read the Docs. The documentation covers installation, usage examples, and version history.
What it is
WTForms-SQLAlchemy is a Python library that connects the WTForms form validation library with SQLAlchemy object-relational mapper. It enables developers to build web forms that work directly with database models without writing repetitive boilerplate code. The project originated as a fork of the deprecated wtforms.ext.sqlalchemy module when WTForms 2.0 removed its extension packages. This separation allows independent releases and focused maintenance. The library targets Python web developers who use Flask, SQLAlchemy, and WTForms together in their applications. It solves the common need to create form fields that query database records and to generate entire forms from model definitions automatically.
This description was generated by AI from the site's public content and may contain errors.
What you can do there
- QuerySelectField for single model instance selection
- QuerySelectMultipleField for multiple model instance selection
- model_form function to generate forms from SQLAlchemy models
- Flask integration example in the examples directory
- Documentation with version history and migration notes
Who it's for
Python web developers using WTForms and SQLAlchemy who need database-driven form handling
Frequently asked questions about wtforms-sqlalchemy.readthedocs.io
›What does WTForms-SQLAlchemy do?
It provides form fields that query SQLAlchemy models and a function to generate forms automatically from model definitions.
›Is WTForms-SQLAlchemy compatible with Flask?
Yes the documentation includes a Flask example and the library works with any framework using WTForms and SQLAlchemy.
›How do I install WTForms-SQLAlchemy?
Run pip install WTForms-SQLAlchemy to add the package to your project environment.
›What fields does the library provide?
It provides QuerySelectField and QuerySelectMultipleField for selecting model instances from database queries.
›Can I generate forms from existing SQLAlchemy models?
Yes the model_form function creates a WTForms form class based on a SQLAlchemy model automatically.
›Why was this package split from WTForms core?
WTForms 2.0 deprecated all ext packages so the authors created a separate project with its own release cycle.
›Where can I find the source code and issue tracker?
Links to the source repository and issue tracker are provided in the project documentation sidebar.
