skillfed

django-postgres-extra

Bringing all of PostgreSQL's awesomeness to Django.

django-postgres-extra v2.0.9 503.8K downloads/30d#6,301 on PyPI762
Permissive license MIT License Active released

What it is and what it does

django-postgres-extra is a Django extension that bridges the gap between Django's generic ORM and PostgreSQL's advanced capabilities. Instead of writing raw SQL or using multiple small packages, it provides a cohesive set of tools—native upserts (single-query, concurrency-safe), HStore field enhancements (unique and null constraints, key-level selection), PostgreSQL 11.x table partitioning (range and list), faster truncate operations, and specialized indexes (conditional unique, case-sensitive unique)—all integrated into Django's migration system so they work seamlessly without manual SQL.

The package targets teams running Django on PostgreSQL who want to leverage database-specific performance and data-modeling features without abandoning the ORM. It depends on Django, python-dateutil, and dataclasses, and supports Python 3.6 through 3.11 and Django 2.0 through 5.0. The project is actively maintained, well-tested (with CircleCI integration and code coverage tracking), and documented via Read The Docs.

Use it for:

  • Implement single-query upserts in high-concurrency scenarios where duplicate-key conflicts are expected and performance matters.
  • Add unique or null constraints to HStore fields and query individual keys without denormalization.
  • Partition large tables by range or list in PostgreSQL 11+ to improve query performance and maintenance on time-series or categorical data.
  • Replace slow Django delete operations with PostgreSQL TRUNCATE for bulk data cleanup.
  • Define conditional or case-sensitive unique indexes to enforce domain-specific uniqueness rules the standard ORM cannot express.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Extends Django's ORM to expose PostgreSQL-specific features like native upserts, HStore field constraints, table partitioning, and specialized indexes through a single integrated package.

Yes. The package is actively maintained, has low install friction, carries a permissive MIT license, and solves real PostgreSQL-specific problems that would otherwise require raw SQL or multiple dependencies. It is a good fit if you are committed to PostgreSQL and want to use its advanced features within Django's ORM without sacrificing code clarity or migrations. Not suitable if you need database portability or are not using PostgreSQL.

Install

django-postgres-extra on PyPI

pip

pip install django-postgres-extra

uv

uv add django-postgres-extra

poetry

poetry add django-postgres-extra

Installing django-postgres-extra

Before you install

Low friction install with a pure-Python wheel. Actively maintained as of July 2026 with recent commits and a stable release history since 2017. Requires Django 2.0+, Python 3.6+, and a PostgreSQL 10+ backend.

License in practice

MIT License permits commercial and private use with minimal restrictions—you may use, modify, and distribute this package freely as long as you include the license notice.

Quickstart

pip install django-postgres-extra

from django_postgres_extra import Manager

class MyModel(models.Model):
    objects = Manager()

# Use native upsert
MyModel.objects.on_conflict(['id']).insert_or_update([obj])

Requires a PostgreSQL 10+ database backend and Django 2.0 or newer; will not work with SQLite or other non-PostgreSQL databases.

Verify before relying

  • Exact scope and completeness of PostgreSQL 11.x declarative table partitioning support (range vs. list vs. hash).
  • Whether concurrent upsert safety extends to all bulk operations or only specific scenarios.
  • Performance characteristics of the faster delete/truncate operations compared to standard Django deletes.

Package facts

License MIT License (permissive)
Python support supports the current Python release (>=3.6)
Install friction low — pure-Python wheel
Runtime dependencies 3 — Django, python-dateutil, dataclasses
Maintenance actively maintained — 399 days since the last release
Last repo commit
First released
Downloads 503,783/month — #6,301 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: django_postgres_extra-2.0.9-py3-none-any.whl

Keywords: django, postgres, extra, hstore, ltree

Environment :: Web EnvironmentFramework :: DjangoIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Internet :: WWW/HTTPTopic :: Internet :: WWW/HTTP :: Dynamic Content

Tags

django postgres upsertpostgresql features django ormdjango hstore constraintspostgres table partitioning djangodjango postgres native operationspostgresql advanced indexes djangobulk upsert django
postgres-orm-extensiondjango-plugin

More WWW/HTTP packages