Edit April 2014:
Celery docs updated for version 3.1; the solution below is deprecated, 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 force celery to use a different name than celery.py by specifying it in the application argument - in this example we will look for celery config in settings.py :
python manage.py celery worker --app=myapp.settings
When using django-celery you can use the above call to start celery or do what I originally did and create celery.py in my celery.py application package:
from settings import celery
My Django settings.py contains the usual celery configuration:
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 as follows:
python manage.py celery worker --app=myapp
Just for clarity, here is my complete application structure:
myproject/ manage.py myapp/ __init__.py settings.py celery.py
mafrosis
source share