Skip to main content

django-native-postgres

Native asynchronous PostgreSQL execution for Django, powered by Rust, Tokio, and tokio-postgres.

Installation

Install the Django fork and the backend together in the same command:

python -m pip install \
    "Django @ git+https://github.com/p-r-a-v-i-n/django.git@312860d0e58e0d54fef10bae7ecf63f537723d17" \
    "django-native-postgres==0.1.1"

This installs Django from the pinned Git commit and the backend wheel from PyPI. Python 3.12 or newer is required. See Django fork requirement for why the fork is currently necessary.

What this project does

django-native-postgres keeps Django's ORM, models, query construction, SQL compiler, relations, and model creation. Compiled SQL is handed to this backend, which performs the database I/O asynchronously without moving that I/O into a sync_to_async() worker thread.

Django async ORM
      |
      v
Django SQL compiler
      |
      v
django-native-postgres (Python)
      |
      v
PyO3 -> Tokio -> Rust-owned PostgreSQL pool
      |
      v
PostgreSQL

This is a PostgreSQL backend for Django. It is not a replacement ORM.

Current capabilities

The project integration suite currently covers:

  • async queryset reads, iteration, values, aggregates, and raw queries;
  • async creates, updates, deletes, bulk operations, and model methods;
  • related managers, prefetching, generic relations, and content types;
  • native async transactions, nested savepoints, rollback state, and on_commit() callbacks;
  • transaction isolation, read-only, and deferrable options;
  • Rust-owned connection pooling with bounded concurrency and acquisition timeouts;
  • cancellation of active and pool-waiting queries;
  • runtime and pool recreation after POSIX fork(), with inherited transaction handles rejected.

See Compatibility for the exact tested surface and current limitations.

Current limitations

Native async execution works for the ORM operations covered by the integration suite, but the project still has the following release limitations:

  • The native async ORM contract exists only in the project's Django fork.
  • Query parameters currently support only strings, integers, and None.
  • Result decoding currently supports text and integer PostgreSQL types.
  • Async iteration is exposed in chunks, but Rust currently buffers the entire result before the first chunk reaches Django.
  • Native PostgreSQL connections currently use NoTls.
  • The project has not yet completed Django's PostgreSQL compatibility suite or a supported platform and PostgreSQL version matrix.

Unsupported native PostgreSQL result types fail explicitly. The Django fork still preserves compatibility fallbacks for backends and custom ORM paths that do not use the native async contract.

Development quick start

Working on the project from source additionally requires:

  • Rust 1.99 or newer;
  • uv;
  • just; and
  • Docker or another Docker-compatible container runtime for PostgreSQL integration tests.

Create the environment and build the native extension:

just setup

Configure the backend through Django's normal DATABASES setting:

DATABASES = {
    "default": {
        "ENGINE": "django_native_postgres",
        "NAME": "application",
        "USER": "application",
        "PASSWORD": "secret",
        "HOST": "127.0.0.1",
        "PORT": "5432",
        "OPTIONS": {
            "native_pool": {
                "max_size": 16,
                "wait_timeout_ms": 30_000,
            },
        },
    }
}

Supported Django async ORM calls then use the native backend path:

from your_app.models import Book


async def find_book(book_id):
    return await Book.objects.aget(pk=book_id)

The complete configuration surface is described in Configuration.

Run formatting, linting, Rust checks, and tests that do not require a live PostgreSQL server:

just check

Run the PostgreSQL integration suite:

just test-postgres

Run one PostgreSQL test:

just test-postgres tests/test_postgres_execution.py::test_name

The test database configuration and other development commands are described in Development.

Documentation

Start with the documentation index. Important references are:

License

Licensed under the BSD 3-Clause License. See LICENSE.

Metadata

Release files for django-native-postgres 0.1.1

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

Source distribution (sdist)

Source distribution for django-native-postgres 0.1.1
File Size Uploaded
django_native_postgres-0.1.1.tar.gz 84.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for django-native-postgres 0.1.1
File
django_native_postgres-0.1.1-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
django_native_postgres-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details
django_native_postgres-0.1.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details
django_native_postgres-0.1.1-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details
django_native_postgres-0.1.1-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details

Total release size: 4.8 MB

Release files / django_native_postgres-0.1.1.tar.gz

Download URL django_native_postgres-0.1.1.tar.gz
Size 84.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a637733a4e9639a462fe355eacead514b124d51d3e470c448f46d69b47e9e495
BLAKE2b-256 checksum
How to use checksums
bab09a52265f1568903553f2a8261b28a754630f5dfb3d1f595d9145426a40d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release files / django_native_postgres-0.1.1-cp312-abi3-win_amd64.whl

Download URL django_native_postgres-0.1.1-cp312-abi3-win_amd64.whl
Size 813.1 kB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
5e5171475fa6a1d5be1d117ca36edb7219f960d4cdc6647066800c0c79bc0caf
BLAKE2b-256 checksum
How to use checksums
d285493fa8693dffe6c1c45a5182f2de256c8572f9987a69d33406342bb73735
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release files / django_native_postgres-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL django_native_postgres-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.0 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
f4f2e8d28a9cb4c3dfc7bef5991c7a7d294f9be0951954764da9be3bb0a7e653
BLAKE2b-256 checksum
How to use checksums
c3b1df62bc5e765bb587b60a4d7de0aabee4831d7cf1f2cbae876e918501ff0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release files / django_native_postgres-0.1.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL django_native_postgres-0.1.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.0 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
7740eb90773f0daa7dbc2093c309ef9d42218e57857add47ddf2dea6c0ddca37
BLAKE2b-256 checksum
How to use checksums
36dd161e5169eef3b7b215fc3b7de4f822d926e23d8612c15406ba47a3afc1c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release files / django_native_postgres-0.1.1-cp312-abi3-macosx_11_0_arm64.whl

Download URL django_native_postgres-0.1.1-cp312-abi3-macosx_11_0_arm64.whl
Size 902.4 kB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
54a79411283820eccdc9e990189a96dea9b688fd2e81d7f1737c9a0310ebfde6
BLAKE2b-256 checksum
How to use checksums
ac5a9fd84e6bba2d414347ecdc3b965a2c420e03f104b8054243e1dc7620b0d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release files / django_native_postgres-0.1.1-cp312-abi3-macosx_10_12_x86_64.whl

Download URL django_native_postgres-0.1.1-cp312-abi3-macosx_10_12_x86_64.whl
Size 938.3 kB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
812cb7bd8162e15c8d7b6c7e6558d949e78c303f443abf42a948f6669d64fb00
BLAKE2b-256 checksum
How to use checksums
0e99cbd2dbb880ff98e12ebca93de1f60dd92e1da877bd038656fb7e23a26edd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

6 release files

0.1.0

6 release files

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