I have created a django-celery application as in the tutorial at:
http://docs.celeryproject.org/en/master/django/first-steps-with-django.html
Everything works fi
Be sure you're trying to start the celery worker from a directory that has access to the celery module. In my case I was trying to start the worker from the app directory rather than the project.
Edit April 2014:
The Celery docs have been updated for 3.1; the below solution is now outdated, see:
http://docs.celeryproject.org/en/master/django/first-steps-with-django.html
By default, celery searches for a module named celery.py
to find its configuration. You can get celery to use a different name than celery.py
by specify it on the app argument - in this example, we'll look for celery config in settings.py
:
python manage.py celery worker --app=myapp.settings
When using django-celery
you can either use the above call to start celery, or do as I originally did and create a celery.py
in my application package myapp
:
from settings import celery
My Django settings.py
contains the normal celery config:
from celery import Celery
celery = Celery(broker="amqp://guest:guest@127.0.0.1:5672//")
celery.conf.update(
CELERY_DEFAULT_QUEUE = "myapp",
CELERY_DEFAULT_EXCHANGE = "myapp",
CELERY_DEFAULT_EXCHANGE_TYPE = "direct",
CELERY_DEFAULT_ROUTING_KEY = "myapp",
)
Then run the celery worker like this:
python manage.py celery worker --app=myapp
Just for clarity's sake, here's my full application structure:
myproject/
manage.py
myapp/
__init__.py
settings.py
celery.py