Does create_pydantic_model use optional fields by design #665
-
In using a model created with I am trying to determine if I am doing something wrong, or if this is by design. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
There's a parameter you can pass to your columns called class MyTable(Table):
name = Varchar(required=True)
MyTableModel = create_pydantic_model(MyTable)
# name is now required:
MyTableModel()
>>> Error! It's not documented well - we need to add a section to this page explaining it: https://piccolo-orm.readthedocs.io/en/latest/piccolo/serialization/index.html# |
Beta Was this translation helpful? Give feedback.
There's a parameter you can pass to your columns called
required
. By default it'sFalse
.create_pydantic_model
uses this to determine if a field is optional or not.It's not documented well - we need to add a section to this page explaining it:
https://piccolo-orm.readthedocs.io/en/latest/piccolo/serialization/index.html#