Skip to content

Instantly share code, notes, and snippets.

@capooti
Created March 26, 2013 13:26
Show Gist options
  • Save capooti/5245341 to your computer and use it in GitHub Desktop.
Save capooti/5245341 to your computer and use it in GitHub Desktop.
Sample wsgi script to be used in Apache for a Django application
ALLDIRS = ['/home/capooti/.venvs/geonode/lib/python2.7/site-packages']
import os
import sys
import site
# Remember original sys.path.
prev_sys_path = list(sys.path)
# Add each new site-packages directory.
for directory in ALLDIRS:
site.addsitedir(directory)
# Reorder sys.path so new directories at the front.
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path
import django.core.handlers.wsgi
os.environ['DJANGO_SETTINGS_MODULE'] = 'geonode.settings'
application = django.core.handlers.wsgi.WSGIHandler()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment