Created
April 28, 2012 18:17
-
-
Save brosner/2521027 to your computer and use it in GitHub Desktop.
Gondor settings with os.environ and local_settings = off
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
# based on a modified Django 1.4 project settings (you will most likely need | |
# to heavily customize this for your project). | |
# Assumed to be in <repo root>/myproject/conf/base.py | |
import os | |
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) | |
PACKAGE_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) | |
TIME_ZONE = "UTC" | |
LANGUAGE_CODE = "en-us" | |
USE_I18N = False | |
USE_L10N = True | |
USE_TZ = True | |
STATICFILES_DIRS = [ | |
os.path.join(PACKAGE_ROOT, "static"), | |
] | |
STATICFILES_FINDERS = [ | |
"django.contrib.staticfiles.finders.FileSystemFinder", | |
"django.contrib.staticfiles.finders.AppDirectoriesFinder", | |
] | |
SECRET_KEY = "..." | |
TEMPLATE_LOADERS = [ | |
"django.template.loaders.filesystem.Loader", | |
"django.template.loaders.app_directories.Loader", | |
] | |
MIDDLEWARE_CLASSES = [ | |
"django.middleware.common.CommonMiddleware", | |
"django.contrib.sessions.middleware.SessionMiddleware", | |
"django.middleware.csrf.CsrfViewMiddleware", | |
"django.contrib.auth.middleware.AuthenticationMiddleware", | |
"django.contrib.messages.middleware.MessageMiddleware", | |
] | |
ROOT_URLCONF = "myproject.urls" | |
WSGI_APPLICATION = "myproject.wsgi.application" | |
TEMPLATE_DIRS = [ | |
os.path.join(PACKAGE_ROOT, "templates"), | |
] | |
INSTALLED_APPS = [ | |
"django.contrib.auth", | |
"django.contrib.contenttypes", | |
"django.contrib.sessions", | |
"django.contrib.sites", | |
"django.contrib.messages", | |
"django.contrib.staticfiles", | |
] |
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
# Assumed to be in <repo root>/myproject/conf/gondor.py | |
# Gondor settings_module = myproject.conf.gondor | |
from .base import * | |
import os | |
import urlparse | |
DEBUG = False | |
TEMPLATE_DEBUG = DEBUG | |
if "GONDOR_DATABASE_URL" in os.environ: | |
urlparse.uses_netloc.append("postgres") | |
url = urlparse.urlparse(os.environ["GONDOR_DATABASE_URL"]) | |
DATABASES = { | |
"default": { | |
"ENGINE": { | |
"postgres": "django.db.backends.postgresql_psycopg2" | |
}[url.scheme], | |
"NAME": url.path[1:], | |
"USER": url.username, | |
"PASSWORD": url.password, | |
"HOST": url.hostname, | |
"PORT": url.port | |
} | |
} | |
if "GONDOR_REDIS_URL" in os.environ: | |
urlparse.uses_netloc.append("redis") | |
url = urlparse.urlparse(os.environ["GONDOR_REDIS_URL"]) | |
GONDOR_REDIS_HOST = url.hostname | |
GONDOR_REDIS_PORT = url.port | |
GONDOR_REDIS_PASSWORD = url.password | |
SITE_ID = 1 # set this to match your Sites setup | |
MEDIA_ROOT = os.path.join(os.environ["GONDOR_DATA_DIR"], "site_media", "media") | |
STATIC_ROOT = os.path.join(os.environ["GONDOR_DATA_DIR"], "site_media", "static") | |
MEDIA_URL = "/site_media/media/" # make sure this maps inside of site_media_url | |
STATIC_URL = "/site_media/static/" # make sure this maps inside of site_media_url | |
FILE_UPLOAD_PERMISSIONS = 0640 | |
LOGGING = { | |
"version": 1, | |
"disable_existing_loggers": False, | |
"formatters": { | |
"simple": { | |
"format": "%(levelname)s %(message)s" | |
}, | |
}, | |
"handlers": { | |
"console":{ | |
"level": "DEBUG", | |
"class": "logging.StreamHandler", | |
"formatter": "simple" | |
} | |
}, | |
"root": { | |
"handlers": ["console"], | |
"level": "INFO", | |
}, | |
"loggers": { | |
# ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment