Dash Pydantic Utils

raw JSON →
0.18.3 verified Fri May 01 auth: no python

Utility library for dash-pydantic-form, providing model handling, validation, and serialization helpers for building dynamic forms with Dash and Pydantic v2. Current version 0.18.3, requires Python >=3.10,<3.14. Active development with frequent releases.

pip install dash-pydantic-utils
error ModuleNotFoundError: No module named 'dash_pydantic_utils'
cause Package not installed or wrong import path after split.
fix
pip install dash-pydantic-utils
error ImportError: cannot import name 'ModelForm' from 'dash_pydantic_form'
cause ModelForm was moved to dash-pydantic-utils in v0.17.
fix
Use 'from dash_pydantic_utils import ModelForm' instead.
error pydantic.errors.PydanticUserError: A custom validation cannot be defined for a field that is not a model field
cause Using Pydantic v1 field validators without proper migration.
fix
Migrate validators to v2 syntax (e.g., @field_validator instead of @validator).
breaking dash-pydantic-utils was split from dash-pydantic-form (around v0.17). Imports from dash_pydantic_form may break. Re-import from dash_pydantic_utils.
fix Change 'from dash_pydantic_form import ModelForm' to 'from dash_pydantic_utils import ModelForm'
deprecated The old 'Form' component (from dash_pydantic_form) is deprecated. Use 'ModelForm' from dash_pydantic_utils instead.
fix Replace 'Form' imports with 'ModelForm' from dash_pydantic_utils.
gotcha ModelForm requires a Pydantic v2 model. Using v1 models will cause validation errors.
fix Ensure your model inherits from pydantic.BaseModel (v2), not v1 BaseModel.

Basic usage creating a form from a Pydantic model.

from dash_pydantic_utils import ModelForm
import dash
from dash import html

app = dash.Dash(__name__)

class MyModel(BaseModel):
    name: str = 'World'

form = ModelForm(MyModel, id='my-form')

app.layout = html.Div([form])

if __name__ == '__main__':
    app.run_server(debug=True)