Skip to content
Advertisement

How start celery worker in Django project

I have a Django project with the directory structure mentioned below. I am trying to use Celery for running tasks in the background. I have facing some trouble while running the worker. Whenever I issue the following command, I get an error.

Command

JavaScript

From the projectdirectory where manage.py resides

ModuleNotFoundError: No module named ‘tasks’

From the projectdirectory where celery.py resides

ModuleNotFoundError: No module named ‘tasks’

From the appdirectory where tasks.py resides

AttributeError: module ‘tasks’ has no attribute ‘celery’

Project Structure

JavaScript

Advertisement

Answer

You should use project name to start celery. Since your celery.py located inside project directory you need to run from the project’s root directory following:

JavaScript

Instead of

JavaScript

Check example here.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement