Bird
0
0

In your Django project, Celery tasks are not discovered. You have tasks.py files in apps. What is a likely cause?

medium📝 Debug Q7 of 15
Django - Celery and Background Tasks
In your Django project, Celery tasks are not discovered. You have tasks.py files in apps. What is a likely cause?
Atasks.py files are empty
Bcelery.py missing app.autodiscover_tasks() call
CCelery worker is not running with --loglevel=debug
DDjango settings missing INSTALLED_APPS entries
Step-by-Step Solution
Solution:
  1. Step 1: Check celery.py configuration

    autodiscover_tasks() is needed to find tasks.py files automatically.
  2. Step 2: Understand effect of missing autodiscover_tasks

    Without it, Celery won't find tasks even if tasks.py exists.
  3. Final Answer:

    celery.py missing app.autodiscover_tasks() call -> Option B
  4. Quick Check:

    Missing autodiscover_tasks = no task discovery [OK]
Quick Trick: Add app.autodiscover_tasks() to celery.py to find tasks [OK]
Common Mistakes:
MISTAKES
  • Assuming empty tasks.py is the cause
  • Thinking worker loglevel affects discovery
  • Forgetting to add apps to INSTALLED_APPS

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes