{"id":22993,"library":"wtforms-alchemy","title":"WTForms-Alchemy","description":"Generates WTForms forms from SQLAlchemy models, reducing boilerplate for Flask and other web frameworks. Current version 0.19.1, with irregular releases.","status":"active","version":"0.19.1","language":"python","source_language":"en","source_url":"https://github.com/kvesteri/wtforms-alchemy","tags":["wtforms","sqlalchemy","orm","form-generator","flask"],"install":[{"cmd":"pip install wtforms-alchemy","lang":"bash","label":"pip install"}],"dependencies":[{"reason":"runtime dependency for form base classes and fields","package":"wtforms","optional":false},{"reason":"required for model introspection and ORM support","package":"sqlalchemy","optional":false}],"imports":[{"note":"","wrong":"","symbol":"ModelForm","correct":"from wtforms_alchemy import ModelForm"},{"note":"wrong submodule, top-level import is correct","wrong":"from wtforms_alchemy.fields import ModelFormField","symbol":"ModelFormField","correct":"from wtforms_alchemy import ModelFormField"},{"note":"","wrong":"","symbol":"UniqueValidator","correct":"from wtforms_alchemy import UniqueValidator"}],"quickstart":{"code":"from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\nfrom wtforms_alchemy import ModelForm\n\nBase = declarative_base()\n\nclass User(Base):\n    __tablename__ = 'user'\n    id = Column(Integer, primary_key=True)\n    name = Column(String(100), nullable=False)\n    email = Column(String(100), nullable=False)\n\nengine = create_engine('sqlite:///')\nBase.metadata.create_all(engine)\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nclass UserForm(ModelForm):\n    class Meta:\n        model = User\n        include = ['name', 'email']\n\nform = UserForm()\nprint(form.name.label.text)","lang":"python","description":"Generate a WTForms form from a SQLAlchemy model."},"warnings":[{"fix":"Upgrade SQLAlchemy to 2.0+ or pin wtforms-alchemy to <0.19.0.","message":"In version 0.19.0, support for SQLAlchemy 1.x was dropped; SQLAlchemy 2.0+ is required.","severity":"breaking","affected_versions":">=0.19.0"},{"fix":"Use ModelFormField for nested forms instead.","message":"The 'inline_models' feature is deprecated and will be removed in a future version.","severity":"deprecated","affected_versions":">=0.18.0"},{"fix":"Register custom type mapping using 'type_mapping' in Meta class.","message":"Auto-generated field types depend on column type mapping; unhandled types raise ValueError. Ensure all model columns map to known WTForms fields.","severity":"gotcha","affected_versions":"all"},{"fix":"Add 'session = session' to Meta class or call init with session=session.","message":"Unique validation requires a SQLAlchemy session to be passed explicitly via Meta's 'session' attribute or set globally.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add a type mapping in the Meta class: 'type_mapping = {ARRAY: StringField}' or similar.","cause":"The column type is not registered in the default type mapping.","error":"wtforms_alchemy.exceptions.UnknownTypeException: Unknown column type: <class 'sqlalchemy.dialects.postgresql.ARRAY'>"},{"fix":"Set 'validators = [UniqueValidator()]' on the field or use 'include_unique' in Meta.","cause":"UniqueValidator is not automatically added; you need to enable it explicitly.","error":"AttributeError: 'ModelForm' object has no attribute 'validate_unique'"},{"fix":"Upgrade to latest version with 'pip install --upgrade wtforms-alchemy'.","cause":"Old versions may have different import paths; ensure version >=0.16.0 or install from PyPI.","error":"ImportError: cannot import name 'ModelForm' from 'wtforms_alchemy'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}