-
QuerySetSingle
now has better code completion -
Created Pydantic models will now have the basic validation elements:
required
is correctly populated for required fieldsnullable
is added to the schema where nulls are acceptedmaxLength
for CharFieldsminimum
&maximum
values for integer fields
To get Pydantic to handle nullable/defaulted fields correctly one should do a
**user.dict(exclude_unset=True)
when passing values to a Model class. -
Added
FastAPI
helper that is based on thestarlette
helper but optionally adds helpers to catch and report with proper errorDoesNotExist
andIntegrityError
Tortoise exceptions. -
Allows a Pydantic model to exclude all read-only fields by setting
exclude_readonly=True
when callingpydantic_model_creator
. -
a Tortoise
PydanticModel
now provides two extra helper functions:from_queryset
: Returns aList[PydanticModel]
which is the format that e.g. FastAPI expectsfrom_queryset_single
: allows one to avoid callingawait
multiple times to get the object and all its related items.