Bird
0
0

You want to send a welcome email to new users without slowing down the signup page. How should you implement this using Django background tasks?

hard📝 Application Q15 of 15
Django - Celery and Background Tasks
You want to send a welcome email to new users without slowing down the signup page. How should you implement this using Django background tasks?
AUse @background to create a task that sends the email, then call it after signup.
BStore the email content in the database and send it manually later.
CAdd a delay in the signup view to simulate sending email later.
DSend the email directly in the signup view after saving the user.
Step-by-Step Solution
Solution:
  1. Step 1: Identify the goal

    The goal is to avoid slowing the signup page by sending email asynchronously.
  2. Step 2: Choose the best approach

    Using @background to create a task that sends the email and calling it after signup queues the email sending without blocking the user.
  3. Step 3: Evaluate other options

    Send the email directly in the signup view after saving the user. blocks the signup. Add a delay in the signup view to simulate sending email later. delays but still blocks. Store the email content in the database and send it manually later. requires manual work and is not automatic.
  4. Final Answer:

    Use @background to create a task that sends the email, then call it after signup. -> Option A
  5. Quick Check:

    Use background task for async email = D [OK]
Quick Trick: Use @background task to send email after signup [OK]
Common Mistakes:
MISTAKES
  • Sending email synchronously in view
  • Adding artificial delays instead of async tasks
  • Relying on manual email sending later

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes