django-postgres-extra brings advanced PostgreSQL features like HStore fields, partitioned models, and enhanced querying capabilities directly into Django's ORM. It seamlessly integrates with Django models and querysets, allowing developers to leverage PostgreSQL-specific functionality without writing raw SQL. The current stable version is 2.0.9, with a 3.0.0 release candidate recently published, indicating an active development and release cadence.
pip install django-postgres-extraVerified import paths — ran on the pinned version, not inferred.
To use `django-postgres-extra`, you must add 'pg_extra' to your `INSTALLED_APPS` in `settings.py`. This example demonstrates defining a model with an `HStoreField`, allowing flexible key-value storage. After adding the app and defining the model, run `python manage.py makemigrations` and `python manage.py migrate`.
Consult the official release notes and documentation for version 3.x upon its stable release. Test thoroughly before upgrading in production environments, particularly if leveraging partitioned models or custom primary keys.
Upgrade to `django-postgres-extra` version `2.0.9` or newer. Alternatively, if upgrading is not immediately possible, manually create the `hstore` extension in your PostgreSQL database: `CREATE EXTENSION IF NOT EXISTS hstore;`.
Add `'pg_extra'` to your `INSTALLED_APPS` list in `settings.py`.
Thoroughly read the `django-postgres-extra` documentation on partitioned models and PostgreSQL's native partitioning features. Plan your partitioning strategy carefully, test migrations extensively, and monitor performance after implementation.