Created
July 27, 2011 13:19
-
-
Save julienb74/1109336 to your computer and use it in GitHub Desktop.
The default settings.py I use in all my Django 1.2 and 1.3 projects. It already depends on Django South and the Django Debug Toolbar. It doesn't use the new static media handling of Django 1.3. This file is inspired by Martin Mahner. (http://www.mahner.or
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
# -*- coding: utf-8 -*- | |
import os | |
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) | |
PROJECT_NAME = os.path.split(PROJECT_ROOT)[-1] | |
# -- DEBUG ----------------------------------------------------------------------------------------- | |
DEBUG = True | |
TEMPLATE_DEBUG = DEBUG | |
INTERNAL_IPS = () | |
# -- E-Mail & Error Notification ------------------------------------------------------------------- | |
ADMINS = ( | |
# ('Your Name', 'your_email@example.com'), | |
) | |
MANAGERS = ADMINS | |
DEFAULT_FROM_EMAIL = 'from-mail@example.com' | |
SERVER_EMAIL = 'error-notify@example.com' | |
EMAIL_SUBJECT_PREFIX = '[%s] ' % PROJECT_NAME | |
EMAIL_HOST = 'localhost' | |
EMAIL_PORT = 25 | |
EMAIL_HOST_USER = '' | |
EMAIL_HOST_PASSWORD = '' | |
EMAIL_USE_TLS = False | |
# -- AUTHENTICATION -------------------------------------------------------------------------------- | |
LOGIN_URL = '/login/' | |
LOGOUT_URL = '/logout/' | |
LOGIN_REDIRECT_URL = '/' | |
# -- I18N & URLS ----------------------------------------------------------------------------------- | |
TIME_ZONE = 'Europe/Berlin' | |
LANGUAGE_CODE = 'en' | |
LANGUAGES = (('en', 'English'), ('de', 'German')) | |
USE_I18N = True | |
SITE_ID = 1 | |
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media') | |
MEDIA_URL = '/media/' | |
ADMIN_MEDIA_PREFIX = '/media/admin/' | |
ROOT_URLCONF = '%s.urls' % PROJECT_NAME | |
# -- DATABASE -------------------------------------------------------------------------------------- | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.mysql', | |
'NAME': PROJECT_NAME, | |
'USER': 'root', | |
'PASSWORD': '', | |
'HOST': '', | |
'PORT': '', | |
'OPTIONS': { 'init_command': 'SET storage_engine=INNODB', } | |
} | |
} | |
# -- APPLICATIONS & MIDDLEWARES -------------------------------------------------------------------- | |
INSTALLED_APPS = ( | |
'django.contrib.auth', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', | |
'django.contrib.sites', | |
'django.contrib.messages', | |
'django.contrib.admin', | |
'debug_toolbar', | |
'south', | |
) | |
MIDDLEWARE_CLASSES = ( | |
'django.middleware.gzip.GZipMiddleware', | |
'django.middleware.common.CommonMiddleware', | |
'django.contrib.sessions.middleware.SessionMiddleware', | |
'django.middleware.csrf.CsrfViewMiddleware', | |
'django.contrib.auth.middleware.AuthenticationMiddleware', | |
'django.contrib.messages.middleware.MessageMiddleware', | |
) | |
TEMPLATE_CONTEXT_PROCESSORS = ( | |
'django.core.context_processors.auth', | |
'django.core.context_processors.debug', | |
'django.core.context_processors.i18n', | |
'django.core.context_processors.media', | |
'django.core.context_processors.request', | |
) | |
TEMPLATE_DIRS = ( | |
os.path.join(PROJECT_ROOT, 'templates'), | |
) | |
TEMPLATE_LOADERS = ( | |
'django.template.loaders.filesystem.Loader', | |
'django.template.loaders.app_directories.Loader', | |
) | |
if not DEBUG: | |
TEMPLATE_LOADERS = ( | |
('django.template.loaders.cached.Loader', ( | |
'django.template.loaders.filesystem.Loader', | |
'django.template.loaders.app_directories.Loader', | |
)), | |
) | |
# -- SECRET KEY ------------------------------------------------------------------------------------ | |
try: | |
SECRET_KEY | |
except NameError: | |
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: | |
Exception('Please create a %s file with random characters to generate your secret key!' % | |
SECRET_FILE) | |
# -- LOCAL SETTINGS -------------------------------------------------------------------------------- | |
try: | |
from settings_local import * | |
except ImportError: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment