Last active
July 9, 2023 09:19
-
-
Save mansha99/5ea8ef171cd0cdb420db5b29da0fa397 to your computer and use it in GitHub Desktop.
project_app_receivers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.dispatch import receiver | |
from helloapp import signals | |
from .models import Notice | |
from django.db.models import signals as modelSignals | |
#Predefined Model signal | |
@receiver(modelSignals.post_save, sender=Notice) | |
def valid_notice_created(sender, instance, created, **kwargs): | |
if created: | |
message = "Notice Created : id = {id} ".format(id=instance.id) | |
print(message) | |
#custom signal | |
@receiver(signals.invalid_notice_signal) | |
def invalid_notice_created(sender, **kwargs): | |
message = "Alert!!! Someone tried to create Invalid notice" | |
print(message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment