def class_prepared_signal_handler(sender, **kwargs): if sender.__name__ == "ActionItem": register = receiver( models.signals.post_save, sender=sender, dispatch_uid="publicweb.models.actionitem_signal_handler") register(actionitem_signal_handler)
def wrapper(sender, instance, raw, using, **kwargs): if raw: instance = sender._default_manager.using(using).get(pk=instance.pk) return receiver(sender=sender, raw=raw, instance=instance, using=using, **kwargs)
class SignalTest(TestCase): def test_post_save(self): created = [] @receiver(post_save, sender=SetModel)
from django.db.models.signals import pre_delete from django.dispatch.dispatcher import receiver from v1.models import Artikel, Slider, Potensi, Lapor def delete_image(sender, instance, **kwargs): instance.gambar.delete(save=False) receiver(pre_delete, sender=Artikel)(delete_image) receiver(pre_delete, sender=Slider)(delete_image) receiver(pre_delete, sender=Potensi)(delete_image) receiver(pre_delete, sender=Lapor)(delete_image)
def class_prepared_signal_handler(sender, **kwargs): if sender.__name__ == "ActionItem": register = receiver(models.signals.post_save, sender=sender, dispatch_uid="publicweb.models.actionitem_signal_handler") register(actionitem_signal_handler)