25.3.1 Informing the User of Login/Logout Actions
To begin, we can create a new file under user/signals.py
.
Our first goal is to import our necessary tools. We need the actual signals from auth as well as the success()
function from the messages app. We then import the @receiver()
decorator, which allows us to register our function to be called when a specific signal is sent, as shown in Example 25.4.
1 from django.contrib.auth.signals import ( 2 user_logged_in, user_logged_out) 3 from django.contrib.messages import success 4 from django.dispatch import receiver
In Example 25.5, we first program display_login_message()
, a function that displays ...
Get Django Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.