django-model-event-actions

The django-model-event-actions package provides tools to replace the Django Signals for a cleaner design and extra functionalities.

Package

https://pypi.org/project/django-model-event-actions/

Source

https://github.com/aryabartar/django-model-event-actions

Contents

Overview

This package is a replacement for the builtin Django Signals which you can define all of the events and actions in the model itself and add conditions to determine when they are triggered. With the help of this package you can track the changed field previous and current values and determine when an action should trigger by creating an event with the decorators in the model.

A simple example will be:

class User(EventActionModel):
    is_active = models.BooleanField()

    @PostSaveEvent(field='is_active', prev=False, now=True)
    def user_deactivated(self):
        # logic

    @PostCreateEvent()
    def post_create(self):
        # logic

To get a feel of how django-model-event-actions works, check out the Tutorial.