Reputation: 33585
I'm unable to get wsgi working on my production server. Running Django 1.4
This is my error.
ImportError: Could not import settings 'Hera.settings' (Is it on sys.path?): No module named Hera.settings
My file project is in /srv/project/Hara/. Example of my file system is below...
/srv/project/Hara/
- manage.py
/srv/project/Hara/Hara
- settings.py
- urls.py
/srv/project/Hara/web
- models
- admin.py
- views.py
/srv/project/Hara/apache
- django.wsgi
django.wsgi
import os
import sys
sys.path.append('/home/ubuntu/project/Hera')
sys.path.append('/home/ubuntu/project/Hera/Hera')
print >> sys.stderr, sys.path
os.environ['DJANGO_SETTINGS_MODULE'] = 'Hera.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Upvotes: 3
Views: 2249
Reputation: 55922
I don't think you're appending the actual directory in your django.wsgi
sys.path.append('/home/ubuntu/project/Hera')
sys.path.append('/home/ubuntu/project/Hera/Hera')
these are no longer applicable on your production site
/srv/project/Hera
even better yet get the path in relation to the file something like:
os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
This way it doesn't matter where your code lives it will always get the
Upvotes: 3