Skip to main content

django-postgres-extra

✅ Tests Verify
📝 License License
📦 PyPi PyPi
🍀 Code coverage Coverage Status
Django Versions 2.0, 2.1, 2.2, 3.0, 3.1, 3.2, 4.0, 4.1, 4.2, 5.0, 5.1, 5.2
Python Versions 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
Psycopg Versions 2, 3
📖 Documentation Read The Docs
⚠️ Upgrade Upgrade from v1.x
🏁 Installation Installation Guide
🔥 Features Features & Documentation
💧 Future enhancements Potential features

django-postgres-extra aims to make all of PostgreSQL's awesome features available through the Django ORM. We do this by taking care of all the hassle. As opposed to the many small packages that are available to try to bring a single feature to Django with minimal effort. django-postgres-extra goes the extra mile, with well tested implementations, seamless migrations and much more.

With seamless we mean that any features we add will work truly seamlessly. You should not have to manually modify your migrations to work with fields and objects provided by this package.


⚠️ This README is for v2. See the v1 branch for v1.x.


Major features

See the full list

  • Conflict handling (atomic upsert)

    Adds support for PostgreSQL's ON CONFLICT syntax for inserts. Supports DO UPDATE and DO NOTHING. Single statement, atomic and concurrency safe upserts. Supports conditional updates as well.

  • Table partitioning

    Adds support for PostgreSQL 11.x declarative table partitioning. Integrated into Django migrations. Supports all types of partitioning. Includes a command to automatically create time-based partitions.

  • Views & materialized views

    Adds support for creating views & materialized views as any other model. Integrated into Django migrations.

  • Locking models & tables

    Support for explicit table-level locks.

  • Creating/dropping schemas

    Support for managing PostgreSQL schemas.

  • Truncating tables

    Support for TRUNCATE TABLE statements (including cascading).

For Django 3.1 and older:

  • Conditional unique index
  • Case insensitive index

For Django 2.2 and older:

  • Unique index
  • HStore unique and required constraints on specific HStore keys

Working with the code

Prerequisites

  • PostgreSQL 14 or newer.
  • Django 5.x or newer.
  • Python 3.11 or newer.

These are just for local development. CI for code analysis etc runs against these. Tests will pass on all Python, Django and PostgreSQL versions documented. Linting, formatting and type-checking the code might not work on other Python and/or Django versions.

Getting started

  1. Clone the repository:

     λ git clone https://github.com/SectorLabs/django-postgres-extra.git
    
  2. Install uv if you don't have it:

    λ curl -LsSf https://astral.sh/uv/install.sh | sh
    
  3. Sync the development/test dependencies (creates .venv and installs from uv.lock):

    λ cd django-postgres-extra
    λ uv sync --extra dev --extra test
    λ source .venv/bin/activate
    

    uv.lock enforces a 3-day dependency cooldown via [tool.uv] exclude-newer in pyproject.toml, so newly-published versions cannot enter your environment until the community has had time to flag malicious releases.

  4. Create a postgres user for use in tests (skip if your default user is a postgres superuser):

    λ createuser --superuser psqlextra --pwprompt
    λ export DATABASE_URL=postgres://psqlextra:<password>@localhost/psqlextra
    

    Hint: if you're using virtualenvwrapper, you might find it beneficial to put the export line in $VIRTUAL_ENV/bin/postactivate so that it's always available when using this virtualenv.

  5. Run the tests:

    λ poe test
    
  6. Run the benchmarks:

    λ poe benchmark
    
  7. Auto-format code, sort imports and auto-fix linting errors:

    λ poe fix
    

Metadata

Release files for django-postgres-extra 3.0.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-postgres-extra 3.0.1
File Size Uploaded
django_postgres_extra-3.0.1.tar.gz 108.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-postgres-extra 3.0.1
File Interpreter ABI Platform
django_postgres_extra-3.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 211.8 kB

Release files / django_postgres_extra-3.0.1.tar.gz

Download URL django_postgres_extra-3.0.1.tar.gz
Size 108.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7c6b435b101852365005fc756ad034345e5d483047bb7b8a40f1911fca34f012
BLAKE2b-256 checksum
How to use checksums
1d021231bf077a17a14f22d72d6157e57d9154ebbd8fea1744b2e2aec628e82f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / django_postgres_extra-3.0.1-py3-none-any.whl

Download URL django_postgres_extra-3.0.1-py3-none-any.whl
Size 103.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57e3e0ecd1144ba4afc515bb21facae2cf764fb0d61a2d347cf8b0b0d39e5e6c
BLAKE2b-256 checksum
How to use checksums
0951b2ff225c7e9b5691347b023731f0c972c77f76f52941ac092cb51dcf6cd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

3.0.1 This release

2 release files

3.0.0

2 release files

2.0.9

2 release files

2.0.8

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

1 release file

2.0.1

1 release file

2.0

1 release file

1.22

1 release file

1.20

1 release file

1.19

1 release file

1.17

1 release file

1.14

1 release file

1.13

1 release file

1.12

1 release file

1.11

1 release file

1.10

1 release file

1.9

1 release file

1.8

1 release file

1.7

1 release file

1.6

1 release file

1.5

1 release file

1.4

1 release file

1.3

1 release file

1.2

1 release file

1.1

1 release file

1.0

1 release file

0.0.0

2 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