ilya-muhortov
9/30/2019 - 6:26 AM

Signals/Receivers

from django.dispatch import receiver
from django.db.models.signals import post_save

from .models import ModelName

__all__ = [
    'model_name_post_create'
]


@receiver(post_save, sender=ModelName)
def model_name_post_create(sender, instance, raw, created, **kwargs):
    pass
import django.dispatch

__all__ = ['new_signal']


new_signal = django.dispatch.Signal(providing_args=['param', 'another_param'])

def handle_new_signal(param1, another_param):
  pass

new_signal.connect(handle_new_signal)

new_signal.send(None, param='param1', another_param='another_param')