Bird
0
0

How can you disconnect a signal handler that was connected using the @receiver decorator?

hard📝 Application Q9 of 15
Django - Signals
How can you disconnect a signal handler that was connected using the @receiver decorator?
ASet <code>handler = None</code> in the signal module
BRemove the <code>@receiver</code> decorator from the handler function
CUse <code>post_save.disconnect(handler, sender=Model)</code> with the handler function reference
DRestart the Django server to clear signal connections
Step-by-Step Solution
Solution:
  1. Step 1: Understand signal disconnection method

    Django signals provide a disconnect method to remove handlers.
  2. Step 2: Use disconnect with handler and sender

    Call post_save.disconnect(handler, sender=Model) passing the original handler function and sender model to disconnect.
  3. Final Answer:

    Use post_save.disconnect(handler, sender=Model) with the handler function reference -> Option C
  4. Quick Check:

    Disconnect signal by calling disconnect with handler and sender [OK]
Quick Trick: Disconnect signals with signal.disconnect(handler, sender=Model) [OK]
Common Mistakes:
MISTAKES
  • Removing decorator does not disconnect signals
  • Assigning handler to None has no effect
  • Restarting server does not clear connections

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes