--- id: wtforms-sqlalchemy version: "0.4.2" license: Copyright (c) 2020 by Thomas Johansson, James Crasta and others. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the… (full text in the JSON record) license_treatment: permissive maintenance: active --- # WTForms-SQLAlchemy — SQLAlchemy tools for WTForms License: permissive · Maintenance: active · Downloads: 122.4K/mo ## What it is and what it does WTForms-SQLAlchemy bridges WTForms and SQLAlchemy by providing form generation and database-aware form fields. It was forked from WTForms' deprecated sqlalchemy extension to maintain independent development and release cycles. The package offers two main features: automatic form generation from SQLAlchemy models via model_form(), and specialized form fields (QuerySelectField, QuerySelectMultipleField) that populate dropdown lists directly from database queries. The package is designed for web applications that need to build forms tied to database models without manually defining each field. It's commonly used in Flask applications where forms need to display related records as choices. With low install friction and active maintenance, it integrates cleanly into projects already using both WTForms and SQLAlchemy. Use it for: - Auto-generate form classes from SQLAlchemy ORM models to reduce boilerplate in CRUD interfaces. - Populate dropdown fields with live database queries (e.g., user lists, category selections) using QuerySelectField. - Build multi-select form fields backed by database relationships without writing custom query logic. - Simplify form validation and data binding when working with SQLAlchemy model instances. - Create admin interfaces or data entry forms that stay synchronized with model schema changes. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Generates WTForms forms from SQLAlchemy models and provides form fields for selecting from database queries. Yes. Low install friction, active maintenance, permissive BSD license, and no known vulnerabilities make this a safe choice. Install it if you're building WTForms-based applications with SQLAlchemy models and want to avoid manual form field definition or need database-backed select fields. ## Install pip install wtforms-sqlalchemy uv add wtforms-sqlalchemy poetry add wtforms-sqlalchemy ## Installing WTForms-SQLAlchemy Before you install: Low install friction with just two runtime dependencies (sqlalchemy and wtforms). Actively maintained as of 2026-04-23 with stable production status. License in practice: BSD license (permissive) — you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions. Quickstart: pip install WTForms-SQLAlchemy from wtforms_sqlalchemy.orm import model_form from wtforms_sqlalchemy.fields import QuerySelectField # Generate a form class from a SQLAlchemy model MyForm = model_form(MyModel) # Or use QuerySelectField for database-backed dropdowns class MyForm(Form): user = QuerySelectField(query_factory=lambda: User.query) Requires Python 3.9 or later; sqlalchemy and wtforms must be installed. Verify before relying: - Whether QuerySelectField and QuerySelectMultipleField support async SQLAlchemy sessions or only synchronous queries. - Compatibility with the latest major versions of sqlalchemy (2.0+) and wtforms (3.x). - Whether model_form supports all SQLAlchemy column types or has known limitations. ## Package facts - License: Copyright (c) 2020 by Thomas Johansson, James Crasta and others. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the… (full text in the JSON record) (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 122.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags sqlalchemy form generation, wtforms database integration, query select field, model to form, sqlalchemy model forms, form-generation, sqlalchemy-integration [View on SkillFed](https://skillfed.io/packages/wtforms-sqlalchemy) · [View on PyPI](https://pypi.org/project/wtforms-sqlalchemy/)