Skip to main content

Postgres trigger support integrated with Django models.

Project description

django-pgtrigger provides primitives for configuring Postgres triggers on Django models.

Models can be decorated with pgtrigger.register and supplied with pgtrigger.Trigger objects. These will automatically be installed after migrations. Users can use Django idioms such as Q and F objects to declare trigger conditions, alleviating the need to write raw SQL for a large amount of use cases.

django-pgtrigger comes built with some derived triggers for expressing common patterns. For example, pgtrigger.Protect can protect operations on a model, such as deletions or updates (e.g. an append-only model). The pgtrigger.Protect trigger can even target protecting operations on specific updates of fields (e.g. don’t allow updates if is_active is False on a model). Another derived trigger, pgtrigger.SoftDelete, can soft-delete models by setting a field to False when a deletion happens on the model.

Read the pgtrigger docs for examples of how to use triggers in practice.

Documentation

View the django-pgtrigger docs here.

Installation

Install django-pgtrigger with:

pip3 install django-pgtrigger

After this, add pgtrigger to the INSTALLED_APPS setting of your Django project.

Contributing Guide

For information on setting up django-pgtrigger for development and contributing changes, view CONTRIBUTING.rst.

Primary Authors

  • @wesleykendall (Wes Kendall)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-pgtrigger-1.0.0.tar.gz (12.4 kB view hashes)

Uploaded Source

Built Distribution

django_pgtrigger-1.0.0-py3-none-any.whl (13.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page