WTForm generator for Pydantic
Project description
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6d3125f417d6001f3839082ba56730892f7a22ffd6077c1e1f5e6615633fa4a
|
|
| MD5 |
cbbab60bd5668a6e6b8f4988e6325559
|
|
| BLAKE2b-256 |
f7f549644f0be2066361c8ed53bc4afb82350955ee8975931b237f0cbc8281e6
|
Provenance
The following attestation bundles were made for formantic-0.1.0.tar.gz:
Publisher:
publish.yml on wnowicki/formantic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
formantic-0.1.0.tar.gz -
Subject digest:
c6d3125f417d6001f3839082ba56730892f7a22ffd6077c1e1f5e6615633fa4a - Sigstore transparency entry: 225872656
- Sigstore integration time:
-
Permalink:
wnowicki/formantic@b6bcb94315ab21df7f0ed5b6bcd8b373e5fd7820 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/wnowicki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b6bcb94315ab21df7f0ed5b6bcd8b373e5fd7820 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0bc635002ebaee870b2e6f3a82032d557051088f5da1963e10f3c58a703f5381
|
|
| MD5 |
ca15ef7aa69447bc60727cd5a9eefc24
|
|
| BLAKE2b-256 |
b5fa3f4e5809285a564df6b063f7a6a9af6c4e6ad48a8dc5456a7752ee46ca29
|
Provenance
The following attestation bundles were made for formantic-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on wnowicki/formantic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
formantic-0.1.0-py3-none-any.whl -
Subject digest:
0bc635002ebaee870b2e6f3a82032d557051088f5da1963e10f3c58a703f5381 - Sigstore transparency entry: 225872658
- Sigstore integration time:
-
Permalink:
wnowicki/formantic@b6bcb94315ab21df7f0ed5b6bcd8b373e5fd7820 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/wnowicki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b6bcb94315ab21df7f0ed5b6bcd8b373e5fd7820 -
Trigger Event:
push
-
Statement type: