test media
[auf_skeleton_django.git] / bin / django.wsgi
CommitLineData
e29df00c
OL
1#! .virtualenv/bin/python
2
3import os
4import sys
5import site
6
e5cceae7
OL
7major, minor = sys.version_info
8PYTHON = "python%s.%s" % (major, minor)
e29df00c 9
7adc7f71 10os.environ['DJANGO_SETTINGS_MODULE'] = '{{ project_name }}.settings.production'
e29df00c
OL
11
12ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
13VENV_DIR = os.path.join(ROOT_DIR, '.virtualenv')
14VENV_PKG_DIR = os.path.join(VENV_DIR, 'lib', PYTHON, 'site-packages')
15
7adc7f71 16sys.path.append(ROOT_DIR)
e29df00c
OL
17
18# extra site-packages
19PATHS = (
20 VENV_PKG_DIR,
21)
22
23# Remember original sys.path.
24prev_sys_path = list(sys.path)
25
26# Add each new site-packages directory.
27for directory in PATHS:
28 site.addsitedir(directory)
29
30# Reorder sys.path so new directories at the front.
31new_sys_path = []
32for item in list(sys.path):
33 if item not in prev_sys_path:
34 new_sys_path.append(item)
35 sys.path.remove(item)
36sys.path[:0] = new_sys_path
37
38from django.core.handlers.wsgi import WSGIHandler
39application = WSGIHandler()
40try:
41 from raven.contrib.django.middleware.wsgi import Sentry
42 application = Sentry(application)
43except:
44 pass