1

I am working on a new project where every developer has his own settings file.

In order to run Django I have to load it like this:

python manage.py runserver --settings="databank_web.settings.dqs.dev_houman"

I have now to integrate Celery 3.1 into the project and this approach is causing me a lot of headache.

I have followed all the steps to integrate the Celery into Django as described here.

I can run Django as usual, but now I have to run celery with my custom Django environment as described in this solution.

DJANGO_SETTINGS_MODULE='databank_web.settings.dqs.dev_houman' celery -A databank_web worker -l info

This seems to get a step further, but I get this error message:

File "/Users/houman/git/venv/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 3, in <module>
from django.contrib.admin import ModelAdmin, actions
ImportError: cannot import name actions

I did some research and followed this solution in order to narrow it down:

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "databank_web.settings.dqs.dev_houman")
from django.contrib.admin import ModelAdmin, actions

This was meant to clarify which error is throwing, however it seems to work just fine. So I am clueless why this is failing within Django environment.

So why am I getting those ImportError: cannot import name actions errors?

Much appreciated

1
  • Since every developer has her own settings file it is likely that you have something wrong in it. Try executing this in a Python shell to track down the real error. Commented Oct 26, 2014 at 9:49

1 Answer 1

0

It sounds more like a circular dependency.

If you followed the guide, you should have created a new file called celery.py.

In celery.py

from __future__ import absolute_import

import os

from celery import Celery

from django.conf import settings

# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings')

app = Celery('proj')

app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

Comment out os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings') because this is trying to overwrite whatever you pass outside the scope.

Then, set the DJANGO_SETTINGS_MODULE variable outside the file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.