I have created a package to make it easy to create and validate forms with Dash and Pydantic: dash-pydantic-form It leverages Pydantic 2 and dash mantine components (0.14) for the heavy lifting and allows auto-generated, customisable forms.
I’m going to use this for work! Past 3 months has been hell, creating constant forms for sites, users, forms within forms all a headache with many long callbacks. This looks awesome, excited to start using this inplace take my star and thanks / congratulations on building out this project.
Wow - I was working on the same thing, but your solution already much more polished! Do you have / plan on adding support for type unions? Let’s say I have the following models,
I was wondering about a good way to do type unions. For now what I’ve been doing is add a type attribute to my models, then the fields that are related to one type or another are conditionally visible based on the value of type.
It would be great to support something more elegant though, happy to take suggestions / PRs!
Curious why the python version is capped at Python <3.13,>=3.10 . I thought most of plotly infrastructure is currently based and being built on <3.8 which is what I build most of my projects with. Just was wondering if this is a limitation on pydantic and if their where plans to update the projects python version.
I built this using some of the more recent Python typing syntax which doesn’t work with 3.8. It could probably all be converted to work with older versions but would be a bit of work.
Sounds , i might jump into the repo and help when i find some time. Would be nice to expand out the coverage a bit. Thanks and nice job on the usage.py really great build of an example of the project
I thought the last few lines of the CI config file (plotly.py/.circleci/config.yml at master · plotly/plotly.py · GitHub) indicated what versions of Python plotly is currently tested against. This suggests 3.8 through to 3.12 for most tests, the exceptions being orca (3.8 only) and percy (3.9 only)
For now it’s pretty basic, there are 4 columns ( which shrinks to only 1 column on mobile size) so you can pick between 1 and 4 columns for each field. Could definitely add more customisation options there.
I just toke the package for a spin. It’s amazing! It saves so much code - and the resulting code is a lot easier to read, clearly expressing the intent
I attempted to work on getting it setup for python >= 3.8.18, was able to get most setup but I’m stuck on the model_form.py specifically the 3 lines of code with: item: Union[BaseModel, Type[BaseModel]] idk if anyone would be interested at taking a crack at it but I have a fork ready to go: GitHub - pip-install-python/dash-pydantic-form: Goal to update to 3.8 and help maintain.