{"repo":"AmbitionEng/django-pgtrigger","free":true,"listed":false,"github":"https://github.com/AmbitionEng/django-pgtrigger","clone":"git clone https://github.com/AmbitionEng/django-pgtrigger.git","description":"Write Postgres triggers for your Django models","language":"Python","stars":644,"topics":["django","postgresql","triggers"],"license":"BSD-3-Clause","category":"databases-storage","readme_excerpt":"django-pgtrigger django-pgtrigger helps you write Postgres triggers for your Django models. Why should I use triggers? Triggers can solve a variety of complex problems more reliably, performantly, and succinctly than application code. For example, Protecting operations on rows or columns ( pgtrigger.Protect ). Making read-only models or fields ( pgtrigger.ReadOnly ). Soft-deleting models ( pgtrigger.SoftDelete ). Snapshotting and tracking model changes (django-pghistory). Enforcing field transitions ( pgtrigger.FSM ). Keeping a search vector updated for full-text search ( pgtrigger.UpdateSearchVector ). Building official interfaces (e.g. enforcing use of User.objects.create user and not User.objects.create ). Versioning models, mirroring fields, computing unique model hashes, and the list goes on... All of these examples require no overridden methods, no base models, and no signal handling. Quick start Install django-pgtrigger with pip3 install django-pgtrigger and add pgtrigger to settings.INSTALLED APPS . pgtrigger.Trigger objects are added to triggers in model Meta . django-pgtrigger comes with several trigger classes, such as pgtrigger.Protect . In the following, we're protecting the model from being deleted: When migrations are created and executed, ProtectedModel will raise an exception anytime a deletion is attempted. Let's extend this example further and only protect deletions on inactive objects. In this example, the trigger conditionally runs when the row being dele","default_branch":null,"files":null,"tree":[],"storefront":"/r/AmbitionEng","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/AmbitionEng/django-pgtrigger/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}