Skip to main content

Framework to create and process triggers.

Project description

[![Coverage Status](](
[![CI Status](](


Django Triggers is a light-weight framework for having one part of an
application generate a trigger while another part responds to to it.
Triggers are persistent and can be scheduled to be processed at a later


Triggers are defined by subclassing the `Trigger` model. `Trigger` defines
common data structures and logic for all child triggers. The only thing a
child should have to do is override the `_process` method and set `typed` to
a unique slug.


General use


from djtriggers.models import Trigger

class BreakfastTrigger(Trigger):
class Meta:
# There is no trigger specific data so make a proxy model.
# This ensures no additional db table is created.
proxy = True
typed = 'breakfast'

def _process(self, dictionary={}):


Trigger specific data


from djtriggers.models import Trigger

class PayBill(Trigger):
class Meta:
# We need a regular model as the trigger specific data needs a
# place to live in the db.
proxy = False

amount = models.IntegerField()
recipient = models.ForeignKey(User)

def _process(self, dictionary={}):
amount = self.amount
recipient = self.recipient
pay_bill(amount, recipient)


Trigger processing


from .models import BreakfastTrigger
from .exceptions import ProcessError

trigger = BreakfastTrigger.objects.get(pk=1)
except ProcessError as e:


Delayed processing


from .models import BreakfastTrigger

trigger = BreakfastTrigger()
# Process 8 hours later (this can be any datetime)
trigger.process_after = now() + timedelta(hour=8)


Project details

Download files

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

Files for django-triggers, version 2.0.13
Filename, size File type Python version Upload date Hashes
Filename, size django_triggers-2.0.13-py2.py3-none-any.whl (20.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size django-triggers-2.0.13.tar.gz (10.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page