Bird
0
0

You want to send a welcome email asynchronously after a user registers. Which approach correctly combines Django signals and Celery tasks to achieve this?

hard📝 Application Q15 of 15
Django - Celery and Background Tasks
You want to send a welcome email asynchronously after a user registers. Which approach correctly combines Django signals and Celery tasks to achieve this?
ACall <code>send_welcome_email(user.id)</code> directly inside the signal handler
BConnect a signal handler that calls <code>send_welcome_email.delay(user.id)</code> after user creation
CUse a signal to call <code>send_welcome_email.run(user.id)</code> synchronously
DCall <code>send_welcome_email.delay()</code> before the user is saved
Step-by-Step Solution
Solution:
  1. Step 1: Understand the goal

    We want to send the email asynchronously after the user is created to avoid slowing registration.
  2. Step 2: Use Django signals with Celery correctly

    Connect a signal (like post_save) to call send_welcome_email.delay(user.id) after user creation, queuing the task.
  3. Final Answer:

    Connect a signal handler that calls send_welcome_email.delay(user.id) after user creation -> Option B
  4. Quick Check:

    Signal + .delay() after save = async email send [OK]
Quick Trick: Use signals to trigger .delay() after user save [OK]
Common Mistakes:
MISTAKES
  • Calling task directly inside signal, blocking request
  • Calling .run() which is synchronous
  • Calling .delay() before user exists in DB

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes