Django and Celery – first hurdle

If you’re getting started with Django and Celery and following the instructions at, then you might hit the following error when you try to run the example to instantiate the ‘add’ task:

% python
>>> from myapp.tasks import add
/Blah/blah/python2.6/site-packages/celery-2.3.3-py2.6.egg/celery/loaders/ NotConfigured: No ‘celeryconfig’ module found! Please make sure it exists and is available to Python.
  “is available to Python.” % (configname, )))

Since no useful information turned up in a Google search for this, I thought I’d post the answer here.

The problem is that Celery doesn’t know that it’s running in the context of a Django app. That information is in your, if you’ve configured it per the django-celery instructions. So, before you can instantiate your task, you need to do two things:

  1. set DJANGO_SETTINGS_MODULE=settings in your environment
  2. import before trying to instantiate your task


% DJANGO_SETTINGS_MODULE=settings python
>>> import settings
>>> from myapp.tasks import add
>>> result = add.delay(5, 2)
>>> result.ready()
>>> result.result
>>> result.successful()



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: