Recall & Review
beginner
What is the purpose of the
@receiver decorator in Django?The
@receiver decorator connects a function to a Django signal, so the function runs automatically when that signal is sent.Click to reveal answer
beginner
How do you import the <code>@receiver</code> decorator in Django?You import it with: <code>from django.dispatch import receiver</code>.Click to reveal answer
intermediate
Explain the role of the signal argument in the
@receiver(signal) decorator.The signal argument tells Django which signal the decorated function should listen to and respond when that signal is sent.
Click to reveal answer
intermediate
What parameters does a receiver function typically accept?
A receiver function usually accepts
sender, instance, and **kwargs to get details about the signal event.Click to reveal answer
intermediate
Why is using the
@receiver decorator better than manually connecting signals with signal.connect()?The
@receiver decorator makes the code cleaner and easier to read by linking the function directly to the signal in one place.Click to reveal answer
What does the
@receiver decorator do in Django?✗ Incorrect
The
@receiver decorator connects a function to a Django signal so it runs when the signal is sent.Which module do you import
@receiver from?✗ Incorrect
You import
@receiver from django.dispatch.What argument do you pass to the
@receiver decorator?✗ Incorrect
You pass the signal you want the function to listen for to the
@receiver decorator.Which of these is NOT a typical parameter of a receiver function?
✗ Incorrect
Receiver functions usually accept
sender, instance, and **kwargs, but not request.Why use the
@receiver decorator instead of signal.connect()?✗ Incorrect
The
@receiver decorator links the function to the signal clearly in one place, improving code readability.Describe how the
@receiver decorator works in Django and why it is useful.Think about how Django signals notify parts of your app and how the decorator helps handle that.
You got /4 concepts.
Explain the typical parameters a receiver function accepts and what information they provide.
Consider what details the function needs to respond properly to the signal.
You got /3 concepts.