Skip to main content

Bringing all of PostgreSQL's awesomeness to Django.

Project description

xdjango-postgres-extra

PyPI version Python versions Django 6 License: MIT

xdjango-postgres-extra is a maintained fork of django-postgres-extra. It extends Django's PostgreSQL backend with features such as atomic upserts, table partitioning, views, materialized views, schema management, and explicit table locking.

The PyPI distribution is named xdjango-postgres-extra. The Python package and existing imports remain named psqlextra.

Compatibility

  • Django: 2.0 through 6.x (Django>=2.0,<7.0)
  • Python: 3.6 through 3.14
  • PostgreSQL: 11 or newer
  • Psycopg: 2 and 3

Django 6 requires Python 3.12 or newer. The 2.1.x release line was verified with Django 6.0.6 and Python 3.14.

Installation

python -m pip install xdjango-postgres-extra

Use the psqlextra database backend in your Django settings:

DATABASES = {
    "default": {
        "ENGINE": "psqlextra.backend",
        "NAME": "my_database",
        "USER": "my_user",
        "PASSWORD": "my_password",
        "HOST": "localhost",
        "PORT": "5432",
    }
}

Add the application when using features that require app registration:

INSTALLED_APPS = [
    # ...
    "django.contrib.postgres",
    "psqlextra",
]

Existing application code continues to use psqlextra imports:

from psqlextra.models import PostgresModel

Features

  • Atomic INSERT ... ON CONFLICT handling with DO UPDATE and DO NOTHING
  • Bulk inserts and upserts
  • PostgreSQL range, list, hash, and default table partitions
  • Time-based partition management
  • Database views and materialized views integrated with migrations
  • PostgreSQL schema creation, deletion, and temporary schemas
  • Explicit model and table locks
  • TRUNCATE TABLE, including cascading truncation
  • HStore constraints and expressions
  • PostgreSQL-specific indexes and introspection

The upstream documentation remains the primary API reference:

When following upstream installation instructions, install xdjango-postgres-extra instead of django-postgres-extra.

Development

Create a virtual environment and install the development extras:

python -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[dev,test]"

Set a PostgreSQL test database URL:

export DATABASE_URL="postgres://psqlextra:password@localhost/psqlextra"

Run the available Poe tasks:

poe test
poe verify

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xdjango_postgres_extra-2.1.2.tar.gz (104.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xdjango_postgres_extra-2.1.2-py3-none-any.whl (100.5 kB view details)

Uploaded Python 3

File details

Details for the file xdjango_postgres_extra-2.1.2.tar.gz.

File metadata

  • Download URL: xdjango_postgres_extra-2.1.2.tar.gz
  • Upload date:
  • Size: 104.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for xdjango_postgres_extra-2.1.2.tar.gz
Algorithm Hash digest
SHA256 db2eb2d8fc98c8e68d0f1cca1b48fb3024645bc5e1061363e22e531fd332d727
MD5 e71d770e2afa3bdf7f2554fca64e9e4a
BLAKE2b-256 5972fa2c27a59ce8fb33c7548679be66dd147bc4dd0284cf52cbfeccb1440368

See more details on using hashes here.

File details

Details for the file xdjango_postgres_extra-2.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for xdjango_postgres_extra-2.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 834913040506d222487fed3506eac89fa56ad9448025ce537f424139e1cac245
MD5 11ff57a1c3fc088ee2f5aab6e649eff0
BLAKE2b-256 f81c41d81a0a7b1d92fd7d9d57b5e4b9b925fd9370277d6c58ca21b875f8d334

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page