Skip to content

Instantly share code, notes, and snippets.

@adamn
Created November 12, 2010 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamn/674303 to your computer and use it in GitHub Desktop.
Save adamn/674303 to your computer and use it in GitHub Desktop.
Example manage.py file for using a settings/ directory
#!/usr/bin/env python
import sys
from os.path import abspath, dirname, join
from django.core.management import execute_manager
try:
from settings import active as settings
except ImportError:
sys.stderr.write("Error: Can't find the module 'active' in the directory containing %r. \
(If the file settings.py does exist, it's causing an ImportError.)\n" % __file__)
try:
from settings import development as settings
except:
sys.stderr.write("Error: Can't find the module 'development' in the directory containing %r. \
(If the file settings.py does exist, it's causing an ImportError.)\n" % __file__)
sys.exit(1)
sys.path.insert(0, abspath(join(dirname(__file__), "../")))
sys.path.insert(0, join(settings.PROJECT_ROOT, "apps"))
if __name__ == "__main__":
execute_manager(settings)
import os, sys
from os.path import abspath, dirname, join
sys.stdout = sys.stderr
sys.path.insert(0, abspath(join(dirname(__file__), "../")))
sys.path.insert(0, abspath(join(dirname(__file__), "../../")))
sys.path.insert(0, abspath(join(dirname(__file__), "../apps")))
os.environ["DJANGO_SETTINGS_MODULE"] = "settings.production"
os.environ["CELERY_LOADER"] = "django"
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment