Custom Signal Example

A snippet showing how to create custom signals in Django.


from django.dispatch import Signal, receiver

# Define custom signal
order_shipped = Signal()

# Receiver
@receiver(order_shipped)
def notify_customer(sender, **kwargs):
    print("Order shipped notification")

# Send signal
order_shipped.send(sender=None)
      
Explanation:
  • A custom signal is defined using the Signal class.
  • Custom signal defined, connected, and triggered successfully.
    • Category Signals
    • Total Views 320
    • Last Modified 18 May, 2026
    • Tags #signals #custom #dispatch #django
    Never miss a story on Django.wiki

    Subscribe for fresh tutorials, snippets, and updates.

    By subscribing you agree to our Privacy Policy.