I'm looking to get my Django project running around the production server.

I setup the atmosphere using pip, so it's just like the expansion atmosphere where things are running fine. The only real difference is the fact that I do not use virtualenv on production, as this project is the only person that's likely to operate on production. Also on production, there's an Nginx reverse proxy for everyone static content, and passes dynamic demands to Apache2.

The Apache wsgi file is the following:

import sys, os


os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

After I access the server, I recieve an import error:

ImproperlyConfigured: Error importing middleware middleware: "cannot import name UserProfile"

Which refers back to the middleware.py under src/ folder that is known through the configurations. However I can import both middleware and also the UserProfile class from inside ./manage.py spend prompt.

It appears like an issue with pathways in wsgi file however i cannot see what. Your directory structure is:

/home/project/src (which contains the settings.py, middleware.py and app folders)

Any assistance is greatly appreciated.

Thanks, oMat

Ensure all sites/files are readable by others to ensure that Apache user can access them, unless of course that's you're running daemon mode with various user just in case that user needs to have the ability to read them. Also read:


It might not help, however the WSGI script file contents referred to at finish of this will make sure process atmosphere is setup nearer to what Django development server does just in case it relates to individuals variations.

Searching inside my own file, I add your directory that consists of the projects, and that i specify project.configurations, not settings


import sys, os


os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

It might be better should you made something similar to ~/django-sites so as you specify that rather than /home