Bird
0
0

Which of the following is the correct way to connect a signal handler to Django's post_save signal?

easy📝 Syntax Q12 of 15
Django - Signals
Which of the following is the correct way to connect a signal handler to Django's post_save signal?
Apost_save.connect(my_handler, sender=MyModel)
Bpost_save.send(my_handler, sender=MyModel)
Cmy_handler.connect(post_save, sender=MyModel)
Dconnect.post_save(my_handler, sender=MyModel)
Step-by-Step Solution
Solution:
  1. Step 1: Recall Django signal connection syntax

    The correct syntax is signal.connect(handler, sender=Model).
  2. Step 2: Match the options to this syntax

    post_save.connect(my_handler, sender=MyModel) matches the correct syntax exactly.
  3. Final Answer:

    post_save.connect(my_handler, sender=MyModel) -> Option A
  4. Quick Check:

    Signal connect syntax = post_save.connect(my_handler, sender=MyModel) [OK]
Quick Trick: Use signal.connect(handler, sender=Model) to connect [OK]
Common Mistakes:
MISTAKES
  • Using send() instead of connect()
  • Reversing handler and signal in connect()
  • Calling connect as a method on handler

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes