Skip to content

Instantly share code, notes, and snippets.

@LeZuse
Created November 7, 2012 15:05
Show Gist options
  • Select an option

  • Save LeZuse/4032125 to your computer and use it in GitHub Desktop.

Select an option

Save LeZuse/4032125 to your computer and use it in GitHub Desktop.
WSGI script with virtualenv activation with Django
"""
WSGI config for csshat project.
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.
Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.
"""
import os
import sys
activate_this = '/var/www/apache/csshat.com/csshat.com/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
path = os.path.join(os.path.dirname(__file__), os.pardir)
if path not in sys.path:
sys.path.append(path)
csshat_path = os.path.join(path, 'csshat')
if csshat_path not in sys.path:
sys.path.append(csshat_path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'csshat.settings_production'
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "csshat.settings_production")
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment