Well what are they? They are hooks that you can listen for in your application and do a specific task when they occur.
You can check the Signal Docs for a more detailed explanation
There are alot of built-in signals
Using Signals Example with User Authentication Signals#
In this example we will be catching the user logout signal with the
django.contrib.auth.signal.user_logged_out and adding a django message
NB First thing to do is make sure the app knows about the signals
You need to import your signals into
from django.apps import AppConfig class UsersConfig(AppConfig): name = 'users' def ready(self): import users.signals
Make sure the Config is loaded in
default_app_config = '<app_name>.apps.<AppConfig>'
signals.pycreate your signal receiver
Remember the parameters available are specified in built-in signal
from django.contrib.auth.signals import user_logged_out from django.dispatch import receiver @receiver(user_logged_out) def add_message_on_logout(sender, request, user, **kwargs): messages.info(request, 'You have been logged out.')
Alternatively you can connect to signals without the
def add_message_on_logout(sender, request, user, **kwargs): messages.info(request, 'You have been logged out.') user_logged_out.connect(add_message_on_logout)