Skip to main content

WTForm generator for Pydantic

Project description

FormAntic

python ruff pytest markdown License: GPLv3

Overview

Form Generator
It is designed to work with Pydantic and WTForms. Especially useful with SQL Admin

Usage

Simple way:

from pydantic import BaseModel, Field
from formantic import Former

class User(BaseModel):
    id: int = Field(..., description="The unique identifier for the user")
    name: str = Field(..., description="The name of the user")
    email: str = Field(..., description="The email address of the user")

# WTForm based on Pydantic model
form = Former(User).gen_form()

form.process()

or with some additional modifications:

from pydantic import BaseModel, Field
from wtforms import StringField
from wtforms.form import BaseForm
from formantic import Former

class User(BaseModel):
    id: int = Field(..., description="The unique identifier for the user")
    name: str = Field(..., description="The name of the user")
    email: str = Field(..., description="The email address of the user")

# Form schema for BAseModel based on Pydantic model
form_schema = Former(User).gen_form_schema()

# Some additional field
form_schema["extra_field"] = StringField(
    "extra_field",
    description="An additional field not in the Pydantic model",
    default="Default Value"
)

form = BaseForm(form_schema)

form.process()

Then work with the form as with normal WTForms

Test

uv run pytest

Security

If you discover any security-related issues, please email email instead of using the issue tracker.


Copyright (c) 2025 Wojciech Nowicki

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

formantic-0.1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

formantic-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file formantic-0.1.0.tar.gz.

File metadata

  • Download URL: formantic-0.1.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for formantic-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c6d3125f417d6001f3839082ba56730892f7a22ffd6077c1e1f5e6615633fa4a
MD5 cbbab60bd5668a6e6b8f4988e6325559
BLAKE2b-256 f7f549644f0be2066361c8ed53bc4afb82350955ee8975931b237f0cbc8281e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for formantic-0.1.0.tar.gz:

Publisher: publish.yml on wnowicki/formantic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file formantic-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: formantic-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for formantic-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0bc635002ebaee870b2e6f3a82032d557051088f5da1963e10f3c58a703f5381
MD5 ca15ef7aa69447bc60727cd5a9eefc24
BLAKE2b-256 b5fa3f4e5809285a564df6b063f7a6a9af6c4e6ad48a8dc5456a7752ee46ca29

See more details on using hashes here.

Provenance

The following attestation bundles were made for formantic-0.1.0-py3-none-any.whl:

Publisher: publish.yml on wnowicki/formantic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page