Bird
0
0

You wrote this in celery.py:

medium📝 Debug Q6 of 15
Django - Celery and Background Tasks
You wrote this in celery.py:
app = Celery('proj')
app.config_from_object('django.conf:settings')
app.autodiscover_tasks()

Why might this cause an error when running Celery?
ACelery app name should be 'django' not 'proj'
BMissing namespace='CELERY' in config_from_object call
Cautodiscover_tasks requires an argument
Dconfig_from_object should be called after autodiscover_tasks
Step-by-Step Solution
Solution:
  1. Step 1: Check config_from_object usage

    When loading Django settings, the namespace='CELERY' argument is needed to load Celery-specific settings.
  2. Step 2: Identify missing argument effect

    Without namespace, Celery may not find its settings and cause errors.
  3. Final Answer:

    Missing namespace='CELERY' in config_from_object call -> Option B
  4. Quick Check:

    config_from_object needs namespace='CELERY' [OK]
Quick Trick: Always add namespace='CELERY' when loading Django settings [OK]
Common Mistakes:
MISTAKES
  • Using wrong app name
  • Thinking autodiscover_tasks needs arguments
  • Calling config_from_object after autodiscover_tasks

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes