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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-model-event-actions-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b40511887e734e8aa21876394842f2985408ddf743451fa01d633723053564e0 |
|
MD5 | 7f7ab377201286b0184e96dd37051859 |
|
BLAKE2b-256 | db15fc00aba1e9c21e4ca0f25a123a11dba0cee40b87e207b4ff33b8a171710b |
Hashes for django_model_event_actions-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48268e0818d96a47aef235c6030fac2aaf4164d316d954b13dabf452839aac61 |
|
MD5 | 6c802c210f3b16fd6f7f7417d2f3e074 |
|
BLAKE2b-256 | 33bb5b1d90ba1d1ec22e3d50a1c25da0c2fbdb0b0a5f1085c319125c6d4cd862 |