Last active
December 12, 2015 01:18
-
-
Save datakop/4689987 to your computer and use it in GitHub Desktop.
wsgi script for production django projects based on virtulenv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
venv = '/PATH_TO_ENVIRONMENT/bin/activate_this.py' | |
execfile(venv, dict(__file__=venv)) | |
import locale | |
locale.setlocale(locale.LC_ALL, 'ru_RU.utf8') | |
import sys | |
import os | |
_PROJECT_DIR = '/PATH_TO_DJANGO_SETTING_FOLDER' # /PATH_TO_DJANGO_PROJECT/mysite/mysite | |
sys.path.insert(0, _PROJECT_DIR) | |
sys.path.insert(0, os.path.dirname(_PROJECT_DIR)) | |
_PROJECT_NAME = _PROJECT_DIR.split('/')[-1] | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "%s.settings" % _PROJECT_NAME) | |
from django.core.wsgi import get_wsgi_application | |
application = get_wsgi_application() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment