django-postgres-extra
Bringing all of PostgreSQL's awesomeness to Django.
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-extrauv
uv add django-postgres-extrapoetry
poetry add django-postgres-extraInstalling 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
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
django-citextProvides PostgreSQL CIText field types for…
permissive · top 15,000 on PyPI
django-pg-zero-downtime-migrationsProvides a Django database backend for…
permissive · top 15,000 on PyPI
django-postgres-copyProvides Django ORM integration for…
permissive · top 5,000 on PyPI
django-pg-migration-toolsProvides safer, production-ready Django…
permissive · top 15,000 on PyPI
django-pgviews-reduxAdds first-class PostgreSQL view support to…
unclear · top 15,000 on PyPI
pangresUpserts pandas DataFrames into PostgreSQL,…
permissive · top 15,000 on PyPI
django-pgtriggerdjango-pgtrigger lets you define PostgreSQL…
permissive · top 5,000 on PyPI
django-query-builderBuilds and executes complex SQL queries…
permissive · top 15,000 on PyPI
django-pg-bulk-updateExecutes bulk update and bulk create operations…
permissive · top 15,000 on PyPI
django-peeringdbProvides Django ORM models and admin interface…
permissive · top 15,000 on PyPI