Primary Authors
@wesleykendall (Wes Kendall)
Postgres trigger support integrated with Django models.
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 your application.
Install django-pgtrigger with:
pip3 install django-pgtrigger
After this, add pgtrigger to the INSTALLED_APPS setting of your Django project.
For information on setting up django-pgtrigger for development and contributing changes, view CONTRIBUTING.rst.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Algorithm | Hash digest | |
---|---|---|
SHA256 | acd543e6e5f62001aec5e3d187b868995464dea35b41d2c06ef54dd4e8ade185 |
|
MD5 | 09971faeb7d3a7d469ce1e43b4c96474 |
|
BLAKE2b-256 | 08a536a1f8f0769e7a01bab66244b176a2e69a241b69dbdbbcc2c5a33bd7a24a |