Skip to main content

A replacement for Django Signals for a cleaner design

Project description

django-model-event-actions |latest-version|

|python-support| |django-support| |pypi| |license|

.. start docs include

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:

.. code-block:: python

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

.. end docs include

.. |latest-version| image:: https://img.shields.io/badge/version-1.1-green :alt: Latest version on PyPI :target: https://pypi.org/project/django-model-event-actions/ .. |python-support| image:: https://img.shields.io/badge/python-%2B3.6-blue :target: https://pypi.org/project/django-model-event-actions/ :alt: Python version .. |django-support| image:: https://img.shields.io/badge/django-%2B2.1-blue :target: https://pypi.org/project/django-model-event-actions/ :alt: Django versions .. |pypi| image:: https://img.shields.io/badge/pypi-1.1-blue :target: https://pypi.org/project/django-model-event-actions/ :alt: Pypi link .. |license| image:: https://img.shields.io/badge/license-MIT-green :alt: Software license :target: https://github.com/aryabartar/django-model-event-actions/blob/master/LICENSE .. _Django: http://www.djangoproject.com/

Installation ++++++++++++

.. start installation include

Get the package from pypi::

$ pip install django-model-event-actions

Subclass the models:

.. code-block:: python

from django_model_event_actions.models import EventActionModel

class MyClass(EventActionModel):
    ...

Add the event decorator:

.. code-block:: python

from django_model_event_actions.models import EventActionModel

class MyClass(EventActionModel):
    name = models.CharField()

    @PostCreateEvent(field='name'):
    def my_handler(self):
        # logic

.. end installation include

Tutorial ++++++++

To start using the package take a look at the documentation_ in readthedocs.

.. _documentation: http://www.djangoproject.com/

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-model-event-actions-1.0.4.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

django_model_event_actions-1.0.4-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file django-model-event-actions-1.0.4.tar.gz.

File metadata

  • Download URL: django-model-event-actions-1.0.4.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2

File hashes

Hashes for django-model-event-actions-1.0.4.tar.gz
Algorithm Hash digest
SHA256 258db2afbbca2654cfe0bbff8ca9649443b07c243555d1c0f24a064c3b8ae866
MD5 1998aa82f841f654bc66f38b12f780a0
BLAKE2b-256 5727a2c4b6befc8095eb7e9c5adec2d41c945e2acf72be8e564f43491bab685b

See more details on using hashes here.

File details

Details for the file django_model_event_actions-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: django_model_event_actions-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2

File hashes

Hashes for django_model_event_actions-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0093e827d22a59570f10bb02f2c04b66be666b14cee939bfdb254424ebb9c3fa
MD5 f3404199eed27f37b3f7a4d8846f554f
BLAKE2b-256 ac067014aa58950c1b2dd00e52faccf3f4827826d8ad6e705349a930f4e29dd5

See more details on using hashes here.

Supported by

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