Django apache-wsgi configuration problem
- by omat
Hi,
I am trying to get my Django project running on the production server.
I setup the environment using pip, so it is identical to the development environment where everything is running fine. The only difference is that I don't use virtualenv on production, because this project is the only one that is going to run on production. Also on production, there is an Nginx reverse proxy to serve static content, and passes dynamic requests to Apache2.
The Apache wsgi file is as follows:
import sys, os
sys.path.append('/home/project/src')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
When I access the server, I get an import error:
ImproperlyConfigured: Error importing middleware middleware: "cannot import name UserProfile"
Which refers to the middleware.py under src/ folder which is referred by the settings. But I can import both the middleware and the UserProfile class from within ./manage.py shell prompt.
It seems like a problem with paths in wsgi file but I cannot see what. The directory structure is:
/home/project
/home/project/src (which contains the settings.py, middleware.py and app folders)
/home/apache/apache.wsgi
Any help is greatly appreciated.
Thanks,
oMat