Skip to main content

tortoise-extensions

Optional extension field types for Tortoise ORM. This package targets Tortoise ORM 0.25.4 and later, but before 1.0 — Tortoise 1.x is not supported yet.

Install

Base package (requires Tortoise ORM in the supported range):

pip install tortoise-extensions

Optional extras:

pip install tortoise-extensions[pydantic]
pip install tortoise-extensions[uuid6]
pip install tortoise-extensions[s3]
pip install tortoise-extensions[pydantic,uuid6,s3]

Usage

Pydantic JSON (pydantic extra)

from pydantic import BaseModel
from tortoise.models import Model

from tortoise_extensions.pydantic import PydanticJSONField


class Settings(BaseModel):
    theme: str = "dark"


class AppConfig(Model):
    settings: PydanticJSONField[Settings] = PydanticJSONField(Settings, default=Settings)

    class Meta:
        table = "app_configs"

PydanticJSONField round-trips through your Pydantic model: it accepts dicts from PostgreSQL JSONB, JSON strings from SQLite, and serializes models with model_dump(mode="json") on save.

UUID v6+ (uuid6 extra)

from tortoise.models import Model

from tortoise_extensions.uuid6 import FutureUUIDField


class Item(Model):
    id: FutureUUIDField = FutureUUIDField(primary_key=True)

    class Meta:
        table = "items"

Primary keys without an explicit default receive a UUID7, from the standard library on Python 3.14+ and the uuid6 package below. PostgreSQL uses the native UUID column type; other backends store CHAR(36).

S3 objects (s3 extra)

from tortoise.models import Model

from tortoise_extensions.s3 import S3Field


class Attachment(Model):
    file = S3Field(null=True)

    class Meta:
        table = "attachments"

The column stores an object key and loads as an S3Object handle (read, write, delete, get_or_write, ...) backed by obstore. Storages are registered per Tortoise app with init_storages, each with its own ssl setting. See the usage docs for details.

Contributing a new extension

  1. Open an issue first — describe the field behavior, SQL types per backend, which Tortoise versions you need, and the proposed optional-extra name (e.g. pip install tortoise-extensions[myextra]).
  2. After maintainers agree on the design, open a PR that includes:
    • Implementation in src/tortoise_extensions/<module>.py
    • Tests under tests/
    • An entry in [project.optional-dependencies] if the field needs third-party packages
    • README and docs updates for the new field
    • ISC SPDX headers on new files (licensor-config.yaml applies)
  3. Run pdm run quality locally before pushing.

Documentation

Published at docs.nicebots.xyz/tortoise-extensions.

pdm install -G docs
pdm run docs:build
pdm run docs:preview
pdm run docs:dev

Development

pdm install -G dev -G test -G docs
pdm run quality

Public APIs use Google-style docstrings; ruff enforces this via convention = "google".

License

ISC.

Metadata

Release files for tortoise-extensions 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tortoise-extensions 0.0.2
File Size Uploaded Provenance Actions
tortoise_extensions-0.0.2.tar.gz 35.7 kB Without provenance Details for tortoise_extensions-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tortoise-extensions 0.0.2
File Interpreter ABI Platform Actions
tortoise_extensions-0.0.2-py3-none-any.whl Python 3 none any Details for tortoise_extensions-0.0.2-py3-none-any.whl

Total release size: 45.8 kB

Release files / tortoise_extensions-0.0.2.tar.gz

Download URL tortoise_extensions-0.0.2.tar.gz
Size 35.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d2440da9970174da9a6fe51e565bf8c07386e695fcf40d0fb0b140fdf90af6f2
BLAKE2b-256 checksum
How to use checksums
1e657ccc216ebbdd26f0a2c5e2e19281990aa277c7a8540a28bc81accf0937c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.29.7 CPython/3.14.10 Linux/7.0.0-1019-azure

Release files / tortoise_extensions-0.0.2-py3-none-any.whl

Download URL tortoise_extensions-0.0.2-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6ffd6605c7ffb3d240c3aea2314b8e2dab0c97d83ad0026bb42fc0f97196b3a
BLAKE2b-256 checksum
How to use checksums
211136cc7a0ea5c527752b667903d86993c46af1cd4fe39418c3933600ae69a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.29.7 CPython/3.14.10 Linux/7.0.0-1019-azure

Security for tortoise-extensions 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page