Bird
0
0

What is the main purpose of the @receiver decorator in Django?

easy📝 Conceptual Q11 of 15
Django - Signals
What is the main purpose of the @receiver decorator in Django?
ATo register a template filter
BTo create a new database model
CTo connect a function to a signal so it runs automatically when the signal is sent
DTo define a URL route in Django
Step-by-Step Solution
Solution:
  1. Step 1: Understand what signals do in Django

    Signals notify parts of your app when something happens, like saving a model.
  2. Step 2: Role of the @receiver decorator

    The decorator links a function to a signal so it runs automatically when the signal is sent.
  3. Final Answer:

    To connect a function to a signal so it runs automatically when the signal is sent -> Option C
  4. Quick Check:

    Receiver decorator connects functions to signals = D [OK]
Quick Trick: Receiver links functions to signals for automatic execution [OK]
Common Mistakes:
MISTAKES
  • Confusing receiver with model or URL definitions
  • Thinking receiver creates models or templates
  • Mixing up signals with URL routing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes