How to fix Django, Apache VirtualHost, mod_wsgi and DJANGO_SETTINGS_MODULE

I’ve spent countless hours trying to fix Django installations running on legacy Apache servers, these usually recurring every few months, a time span long enough to forget how the last fix was done. And for some reason, the docs are not mentioning this crucial features AT ALL! In the official Django + mod_wsgi documentation page, they don’t mention something so irrelevant such as THE MAIN DJANGO SETTINGS FILE?

For future memory, here's a solution that makes me happy, and hopefully next time will only be a few minutes headache (although I already know it won't be the case...)

- copy the default to a new file called

- modify the new so that it reads:

import os
import mod_wsgi
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project_name.settings.%s" % mod_wsgi.process_group)

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

- now open your virtualhost configuration file and check it contains the following

WSGIScriptAlias / /path/to/your/
WSGIDaemonProcess pick_settings_file_name processes=2 threads=15 python-path=/path/to/virtualenv/lib/python2.7/site-packages:/path/to/django/project
WSGIProcessGroup pick_settings_file_name

- almost there! create a /settings folder sibling of, put an empty in it, then move inside that folder, rename it to and create a new with a single liner in it

from .common import *


just restart your apache and everything will work. in your you will have configurations specific for your environment (i.e. multiple copies of the file for dev, staging:,