github tortoise/tortoise-orm 0.16.1
v0.16.1

latest releases: 0.20.0, 0.19.3, 0.19.2...
4 years ago
  • 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.

Don't miss a new tortoise-orm release

NewReleases is sending notifications on new releases.