Skip to content

v0.16.1

Compare
Choose a tag to compare
@grigi grigi released this 18 Mar 08:12
· 843 commits to develop since this release
  • QuerySetSingle now has better code completion

  • Created Pydantic models will now have the basic validation elements:

    • required is correctly populated for required fields
    • nullable is added to the schema where nulls are accepted
    • maxLength for CharFields
    • minimum & 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 the starlette helper but optionally adds helpers to catch and report with proper error DoesNotExist and IntegrityError Tortoise exceptions.

  • Allows a Pydantic model to exclude all read-only fields by setting exclude_readonly=True when calling pydantic_model_creator.

  • a Tortoise PydanticModel now provides two extra helper functions:

    • from_queryset: Returns a List[PydanticModel] which is the format that e.g. FastAPI expects
    • from_queryset_single: allows one to avoid calling await multiple times to get the object and all its related items.