Created
December 9, 2008 17:39
-
-
Save kogakure/33996 to your computer and use it in GitHub Desktop.
Python: Django Templates: settings.py, local_settings.py
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 | |
# -*- coding: utf-8 -*- | |
import os.path | |
import sys | |
# Basic Settings | |
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) | |
PROJECT_NAME = os.path.split(PROJECT_ROOT)[-1] | |
MEDIA_ROOT = '%s/media/' % PROJECT_ROOT | |
sys.path.insert(0, os.path.join(PROJECT_ROOT, 'applications')) | |
# Debug Settings | |
DEBUG = False | |
TEMPLATE_DEBUG = DEBUG | |
# Local Settings | |
TIME_ZONE = 'Europe/Berlin' | |
LANGUAGE_CODE = 'de-de' | |
USE_I18N = True | |
DEFAULT_CHARSET = 'utf-8' | |
# Site Settings | |
SITE_ID = 1 | |
ROOT_URLCONF = '%s.urls' % PROJECT_NAME | |
APPEND_SLASH = False | |
REMOVE_WWW = False | |
# Middleware | |
MIDDLEWARE_CLASSES = ( | |
'django.middleware.common.CommonMiddleware', | |
'django.contrib.sessions.middleware.SessionMiddleware', | |
'django.contrib.auth.middleware.AuthenticationMiddleware', | |
'django.contrib.redirects.middleware.RedirectFallbackMiddleware', | |
'django.middleware.doc.XViewMiddleware', | |
) | |
# Template Settings | |
TEMPLATE_CONTEXT_PROCESSORS = ( | |
# 'lib.context_processors.media_url', | |
# 'lib.context_processors.web_url', | |
# 'lib.context_processors.django_version', | |
'django.core.context_processors.auth', | |
'django.core.context_processors.request', | |
) | |
TEMPLATE_DIRS = ( | |
'%s/templates' % PROJECT_ROOT, | |
) | |
TEMPLATE_LOADERS = ( | |
'django.template.loaders.filesystem.load_template_source', | |
'django.template.loaders.app_directories.load_template_source', | |
) | |
# Fixture Settings | |
FIXTURE_DIRS = ( | |
'%s/fixtures' % PROJECT_ROOT, | |
) | |
# Secret Key Generator | |
if not hasattr(globals(), 'SECRET_KEY'): | |
SECRET_FILE = os.path.join(PROJECT_ROOT, 'secret.txt') | |
try: | |
SECRET_KEY = open(SECRET_FILE).read().strip() | |
except IOError: | |
try: | |
from random import choice | |
SECRET_KEY = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)]) | |
secret = file(SECRET_FILE, 'w') | |
secret.write(SECRET_KEY) | |
secret.close() | |
except IOError: | |
raise Exception('Please create a %s file with random characters to generate your secret key!' % SECRET_FILE) | |
# Import Local settings | |
try: | |
from settings_local import * | |
except ImportError: | |
try: | |
from mod_python import apache | |
apache.log_error('local_settings.py not set; using default settings', apache.APLOG_NOTICE) | |
except ImportError: | |
import sys | |
sys.stderr.write('local_settings.py not set; using default settings\n') |
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 | |
# -*- coding: utf-8 -*- | |
import platform | |
LOCAL_DEVELOPMENT = ('webfaction.com' not in platform.node()) | |
if LOCAL_DEVELOPMENT: | |
# Debug Settings | |
DEBUG = True | |
TEMPLATE_DEBUG = DEBUG | |
# Database Settings | |
DATABASE_ENGINE = 'sqlite3' | |
DATABASE_NAME = 'dev.db' | |
# Media Settings | |
WEB_URL = 'http://127.0.0.1:8000/' | |
MEDIA_URL = '%smedia/' % WEB_URL | |
ADMIN_MEDIA_PREFIX = '/admin_media/' | |
# Cache Settings | |
CACHE_BACKEND = 'dummy:///' | |
else: | |
# Debug Settings | |
DEBUG = False | |
TEMPLATE_DEBUG = DEBUG | |
# Database Settings | |
DATABASE_ENGINE = 'postgresql_psycopg2' | |
DATABASE_NAME = 'DATABASE_NAME' | |
DATABASE_USER = 'DATABASE_USER' | |
DATABASE_PASSWORD = 'DATABASE_PASSWORD' | |
DATABASE_HOST = 'localhost' | |
# Media Settings | |
WEB_URL = 'http://domain.de/' | |
MEDIA_URL = 'http://media.domain.de/' | |
ADMIN_MEDIA_PREFIX = 'http://media.domain.de/admin_media/' | |
# Cache Settings | |
CACHE_BACKEND = 'memcached://IP:PORT/' | |
# Email Settings | |
ADMINS = (('Max Mustermann', '[email protected]'),) | |
MANAGERS = ADMINS | |
DEFAULT_FROM_EMAIL = '[email protected]' | |
SERVER_EMAIL = '[email protected]' | |
EMAIL_HOST = 'SMTP' | |
EMAIL_HOST_USER = 'SMTP_USER' | |
EMAIL_HOST_PASSWORD = 'SMTP_USER_PASSWORD' | |
EMAIL_PORT = '587' | |
# Application Settings | |
INSTALLED_APPS = ( | |
# Project Applications | |
# Plugins | |
# Django Core | |
'django.contrib.auth', | |
'django.contrib.markup', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', | |
'django.contrib.flatpages', | |
'django.contrib.redirects', | |
'django.contrib.sites', | |
'django.contrib.admin', | |
'django.contrib.admindocs', | |
'django.contrib.sitemaps', | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment