I\'ve deployed Django to Apache via mod_wsgi
. Django is running fine when hosted from Apache. However, I\'m trying to do some maintenance via manage.py
Since your web app is working, check that you're running manage.py
with the same python interpreter that's defined in your .wsgi file (and if you append other directories to sys.path in your .wsgi file, make sure they're in the pythonpath here too).
If you try to import something in your settings file that throws an ImportError, Django tells you settings cannot be imported. Newer versions of django will mention (If the file settings.py does indeed exist, it's causing an ImportError somehow.)
and I've run into this a few times.
If it's not that, maybe try using django-admin.py instead, just in case something has gone wrong in your manage.py file. AFAIK there is no good reason to modify manage.py directly.
Though Simon Whitaker's answer (that a same-name dir is confusing things) is certainly on point, rather than suggesting you change your entire extant dir structure, might I suggest:
Instead of using the "malfunctioning" / ambiguous...
import settings
...use the more specific...
from django.conf import settings
I had accidentally changed my DJANGO_SETTINGS_MODULE
variable using the echo command: echo DJANGO_SETTINGS_MODULE=mysite.settings
I simply quit virtualenv and activated it again, which restored my settings.
Please check for compatibility between the virtualenv version and the django version. when it matches, it works like a gem.
For me it was actually the PATH, so the project wasn't inside the path, I did this:
export PYTHONPATH=/var/www/project:$PYTHONPATH
If it's a local project it might be something like this:
export PYTHONPATH=~/my-project:$PYTHONPATH
Questions? comment and I'll answer.
I had DJANGO_SETTINGS_MODULE set to "mealer.settings"
(django-env)ali@a-N750JV:~/snap/projects-on-django/Rester$ export -p | grep DJANGO
declare -x DJANGO_SETTINGS_MODULE="mealer.settings"
which I removed by
ali@ali-N750JV:~/snap/projects-on-django/Rester$ export -n DJANGO_SETTINGS_MODULE
(django-env)ali@ali-N750JV:~/snap/projects-on-django/Rester$ export -p | grep DJAN
(django-env)ali@ali-N750JV:
export -p | grep DJAN found nothing as you see
this answer is based on answer by Paul Meinshausen