Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Quality

QualityBadge

Test coverage

CoverageBadge

License

LicenseBadge

PyPi

PyPiBadge

Django versions

>=1.11 (including 2.0)

Python versions

>=3.5

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.

Documentation

Major features

  1. Native upserts

    • Single query

    • Concurrency safe

    • With bulk support (single query)

  2. Extended support for HStoreField

    • Unique constraints

    • Null constraints

    • Select individual keys using .values() or .values_list()

  3. Extra signals

    • Updates

  4. Extra expressions

    • MIN and MAX for multiple value fields such as hstore and array.

  5. Indexes

    • Custom indexes with conditions.

Desired/future features

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?

    We utilize PostgreSQL’s hstore data type, which allows you to store key-value pairs in a column. In order to create UNIQUE constraints on specific key, we need to create a special type of index. We could do this without a custom database back-end, but it would require everyone to manually write their migrations. By using a custom database back-end, we added support for this. When changing the uniqueness constraint on a HStoreField, our custom database back-end takes care of creating, updating and deleting these constraints/indexes in the database.

  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. Which Django versions does this package work with?

    Django 1.11 or newer (that includes Django 2.0).

Working with the code

Prerequisites

  • PostgreSQL 9.6 or newer.

  • Django 1.11 or newer.

  • Python 3.5 or newer.

Getting started

  1. Clone the repository:

    λ git clone https://github.com/SectorLabs/django-postgres-extra.git
  2. Create a virtual environment:

    λ cd django-postgres-extra
    λ virtualenv env
    λ source env/bin/activate
  3. Create a postgres user for use in tests (skip if your default user is a postgres superuser):

    λ createuser --superuser psqlextra --pwprompt
    λ export DATABASE_URL=postgres://psqlextra:<password>@localhost/psqlextra

    Hint: if you’re using virtualenvwrapper, you might find it beneficial to put the export line in $VIRTUAL_ENV/bin/postactivate so that it’s always available when using this virtualenv.

  4. Install the development/test dependencies:

    λ pip install -r requirements/test.txt
  5. Run the tests:

    λ tox
  6. Run the benchmarks:

    λ py.test -c pytest-benchmark.ini

Metadata

Release files for django-postgres-extra-kauffman 1.21a12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-postgres-extra-kauffman 1.21a12
File Size Uploaded Provenance Actions
django-postgres-extra-kauffman-1.21a12.tar.gz 34.1 kB Without provenance Details for django-postgres-extra-kauffman-1.21a12.tar.gz

Release files / django-postgres-extra-kauffman-1.21a12.tar.gz

Download URL django-postgres-extra-kauffman-1.21a12.tar.gz
Size 34.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7c2f942e8bb09004f5209902267c054a65fd04df513efd02c593d442aef399e2
BLAKE2b-256 checksum
How to use checksums
e698129cf88e6687462482ec419836a87f48832488f7c30543f1119deff46075
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-postgres-extra-kauffman 1.21a12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page