Bird
0
0

You want to send a custom signal when a blog post is published. Which steps correctly describe the signal dispatch process to achieve this?

hard📝 Application Q15 of 15
Django - Signals
You want to send a custom signal when a blog post is published. Which steps correctly describe the signal dispatch process to achieve this?
AOverride the save method without using signals, then print a message
BCall the receiver function directly without connecting it to a signal
CUse Django's built-in signals only; custom signals are not supported
DDefine a custom Signal, connect a receiver with @receiver decorator, then send the signal when publishing
Step-by-Step Solution
Solution:
  1. Step 1: Define a custom Signal

    Create a Signal instance to represent the blog post published event.
  2. Step 2: Connect a receiver function

    Use the @receiver decorator or signal.connect to attach a function that reacts to the signal.
  3. Step 3: Send the signal when publishing

    Call signal.send(sender=..., instance=...) at the point where the blog post is published.
  4. Final Answer:

    Define a custom Signal, connect a receiver with @receiver decorator, then send the signal when publishing -> Option D
  5. Quick Check:

    Custom signal + receiver + send = correct process [OK]
Quick Trick: Custom signals need definition, connection, and sending [OK]
Common Mistakes:
MISTAKES
  • Trying to use only built-in signals for custom events
  • Calling receiver directly without signal
  • Overriding save without signals when signals are needed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes