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.
Browse the documentation at: http://django-postgres-extra.readthedocs.io
- Single query, concurrency safe upserts, or safely ignoring a duplicate insert.
- Unique and not null constraints for HStoreField.
- Materialized views with migration support.
- Signals for updates.
Install the package from PyPi:
$ pip install django-postgres-extra
Add
postgres_extraanddjango.contrib.postgresto yourINSTALLED_APPS:INSTALLED_APPS = [ .... 'django.contrib.postgres', 'psqlextra' ]Set the database engine to
psqlextra.backend:DATABASES = { 'default': { ... 'ENGINE': 'psqlextra.backend' } }
Make sure all models that inherit from
psqlextra.models.PostgresModelor use thepsqlextra.manager.PostgresManager. Without this, most features do not work.
Why do I need to change the database back-end/engine?
Many of our custom implementations require custom migration implementations as well. Currently the only way tto make that happen is to implement a custom database back-end. Our database back-end simply sits on top of the PostgreSQL back-end that comes with Django.
I am already using a custom database back-end, can I still use yours?
Yes. You can set the
POSTGRES_EXTRA_DB_BACKEND_BASEsetting to your current back-end. This will instruct our custom database back-end to inherit from the database back-end you specified. Warning: this will only work if the base you specified indirectly inherits from the standard PostgreSQL database back-end.Does this package work with Python 2?
No. Only Python 3.5 or newer is supported. We're using type hints. These do not work well under older versions of Python.
Does this package work with Django 1.X?
No. Only Django 1.10 or newer is supported.
On which Django versions has this package been tested?
- Django 1.10
- Django 1.11
Is this used in production?
Yes. We're actively using this in production. Our other open-source package (django-localized-fields) also uses this library, and also that one is actively used in production. There are various other people who have been using these packages in production.