Skip to content

simonschmidt/django-postgres-extra

 
 

Repository files navigation

django-postgres-extra

https://scrutinizer-ci.com/g/SectorLabs/django-postgres-extra/badges/quality-score.png https://scrutinizer-ci.com/g/SectorLabs/django-postgres-extra/badges/coverage.png

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

Major features

  • 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.

Installation

  1. Install the package from PyPi:

    $ pip install django-postgres-extra
  2. Add postgres_extra and django.contrib.postgres to your INSTALLED_APPS:

    INSTALLED_APPS = [
        ....
    
        'django.contrib.postgres',
        'psqlextra'
    ]
  3. Set the database engine to psqlextra.backend:

    DATABASES = {
        'default': {
            ...
            'ENGINE': 'psqlextra.backend'
        }
    }
  4. Make sure all models that inherit from psqlextra.models.PostgresModel or use the psqlextra.manager.PostgresManager. Without this, most features do not work.

FAQ - Frequently asked questions

  1. 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.

  2. I am already using a custom database back-end, can I still use yours?

    Yes. You can set the POSTGRES_EXTRA_DB_BACKEND_BASE setting 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.

  3. 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.

  4. Does this package work with Django 1.X?

    No. Only Django 1.10 or newer is supported.

  5. On which Django versions has this package been tested?

    • Django 1.10
    • Django 1.11
  6. 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.

About

Bringing all of PostgreSQL's awesomeness to Django.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%