Custom Signals & Receivers
You can create custom signals for your own events — like when an order is placed, a payment is processed, or content is published. Custom signals decouple your app components and make your code more modular.
15 min•By Priygop Team•Updated 2026
Creating Custom Signals
- django.dispatch.Signal() — Create a custom signal
- signal.send(sender, **kwargs) — Send the signal
- @receiver(signal) — Connect a handler
- providing_args is deprecated (just document expected kwargs)
- Use signals for cross-app communication
- Avoid excessive signals — they can make debugging harder
Custom Signal
Custom Signal
# blog/signals.py
# from django.dispatch import Signal
# Define custom signals
# post_published = Signal() # Sent when a post is published
# order_completed = Signal() # Sent when an order is completed
# Send signal when post is published
# blog/models.py
# class Post(models.Model):
# def publish(self):
# self.published = True
# self.published_at = timezone.now()
# self.save()
# # Send signal
# from .signals import post_published
# post_published.send(sender=self.__class__, post=self)
# Receive signal in another app
# notifications/handlers.py
# from django.dispatch import receiver
# from blog.signals import post_published
# @receiver(post_published)
# def notify_subscribers(sender, post, **kwargs):
# subscribers = post.author.followers.all()
# for subscriber in subscribers:
# Notification.objects.create(
# user=subscriber,
# message=f"New post: {post.title}",
# )
# @receiver(post_published)
# def update_search_index(sender, post, **kwargs):
# # Update search engine index
# search_index.update(post)Tip
Tip
Use Django's built-in signals (pre_save, post_save, pre_delete) before creating custom signals. They cover most use cases.
Diagram
Loading diagram…
QuerySets are LAZY — no DB hit until evaluated.
Common Mistake
Warning
Overusing signals for business logic. Signals create hidden dependencies. Use explicit function calls for important logic.
Practice Task
Note
(1) Create a custom signal for order completion. (2) Connect handlers for email and inventory. (3) Test signal dispatching.
Quick Quiz
Key Takeaways
- You can create custom signals for your own events — like when an order is placed, a payment is processed, or content is published.
- django.dispatch.Signal() — Create a custom signal
- signal.send(sender, **kwargs) — Send the signal
- @receiver(signal) — Connect a handler