Mercurial > public > bravenewsurf
comparison bns_website/settings/base.py @ 1:134fbfc4acf6
Restructured settings as a directory to allow for different settings files. E.g.
python manage.py runserver --settings=settings.local
Load secret/sensitive information from settings/secrets.json, which will not be controlled in source control.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 27 Oct 2011 20:01:37 -0500 |
parents | bns_website/settings.py@c8881d9ca347 |
children | 920ba6593732 |
comparison
equal
deleted
inserted
replaced
0:c8881d9ca347 | 1:134fbfc4acf6 |
---|---|
1 # Django base settings for bns_website project. | |
2 | |
3 import json | |
4 import os | |
5 | |
6 PROJECT_PATH = os.path.abspath(os.path.join(os.path.split(__file__)[0], '..')) | |
7 | |
8 DEBUG = True | |
9 TEMPLATE_DEBUG = DEBUG | |
10 | |
11 ADMINS = [ | |
12 ('Brian Neal', 'bgneal@gmail.com'), | |
13 ] | |
14 | |
15 MANAGERS = ADMINS | |
16 | |
17 DATABASES = { | |
18 'default': { | |
19 'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. | |
20 'NAME': '', # Or path to database file if using sqlite3. | |
21 'USER': '', # Not used with sqlite3. | |
22 'PASSWORD': '', # Not used with sqlite3. | |
23 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. | |
24 'PORT': '', # Set to empty string for default. Not used with sqlite3. | |
25 } | |
26 } | |
27 | |
28 # Local time zone for this installation. Choices can be found here: | |
29 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name | |
30 # although not all choices may be available on all operating systems. | |
31 # On Unix systems, a value of None will cause Django to use the same | |
32 # timezone as the operating system. | |
33 # If running in a Windows environment this must be set to the same as your | |
34 # system time zone. | |
35 TIME_ZONE = 'America/Chicago' | |
36 | |
37 # Language code for this installation. All choices can be found here: | |
38 # http://www.i18nguy.com/unicode/language-identifiers.html | |
39 LANGUAGE_CODE = 'en-us' | |
40 | |
41 SITE_ID = 1 | |
42 | |
43 # If you set this to False, Django will make some optimizations so as not | |
44 # to load the internationalization machinery. | |
45 USE_I18N = False | |
46 | |
47 # If you set this to False, Django will not format dates, numbers and | |
48 # calendars according to the current locale | |
49 USE_L10N = True | |
50 | |
51 # Absolute filesystem path to the directory that will hold user-uploaded files. | |
52 # Example: "/home/media/media.lawrence.com/media/" | |
53 MEDIA_ROOT = os.path.join(PROJECT_PATH, '..', 'media') | |
54 | |
55 # URL that handles the media served from MEDIA_ROOT. Make sure to use a | |
56 # trailing slash. | |
57 # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" | |
58 MEDIA_URL = '/media/' | |
59 | |
60 # Absolute path to the directory static files should be collected to. | |
61 # Don't put anything in this directory yourself; store your static files | |
62 # in apps' "static/" subdirectories and in STATICFILES_DIRS. | |
63 # Example: "/home/media/media.lawrence.com/static/" | |
64 STATIC_ROOT = os.path.join(PROJECT_PATH, '..', 'static') | |
65 | |
66 # URL prefix for static files. | |
67 # Example: "http://media.lawrence.com/static/" | |
68 STATIC_URL = '/static/' | |
69 | |
70 # URL prefix for admin static files -- CSS, JavaScript and images. | |
71 # Make sure to use a trailing slash. | |
72 # Examples: "http://foo.com/static/admin/", "/static/admin/". | |
73 ADMIN_MEDIA_PREFIX = '/static/admin/' | |
74 | |
75 # Additional locations of static files | |
76 STATICFILES_DIRS = [ | |
77 # Put strings here, like "/home/html/static" or "C:/www/django/static". | |
78 # Always use forward slashes, even on Windows. | |
79 # Don't forget to use absolute paths, not relative paths. | |
80 os.path.join(PROJECT_PATH, 'static'), | |
81 ] | |
82 | |
83 # List of finder classes that know how to find static files in | |
84 # various locations. | |
85 STATICFILES_FINDERS = ( | |
86 'django.contrib.staticfiles.finders.FileSystemFinder', | |
87 'django.contrib.staticfiles.finders.AppDirectoriesFinder', | |
88 # 'django.contrib.staticfiles.finders.DefaultStorageFinder', | |
89 ) | |
90 | |
91 # Make this unique, and don't share it with anybody. | |
92 SECRETS = json.load(open(os.path.join(PROJECT_PATH, 'settings', 'secrets.json'))) | |
93 SECRET_KEY = SECRETS['SECRET_KEY'] | |
94 | |
95 # List of callables that know how to import templates from various sources. | |
96 TEMPLATE_LOADERS = ( | |
97 'django.template.loaders.filesystem.Loader', | |
98 'django.template.loaders.app_directories.Loader', | |
99 # 'django.template.loaders.eggs.Loader', | |
100 ) | |
101 | |
102 MIDDLEWARE_CLASSES = [ | |
103 'django.middleware.common.CommonMiddleware', | |
104 'django.contrib.sessions.middleware.SessionMiddleware', | |
105 'django.middleware.csrf.CsrfViewMiddleware', | |
106 'django.contrib.auth.middleware.AuthenticationMiddleware', | |
107 'django.contrib.messages.middleware.MessageMiddleware', | |
108 ] | |
109 | |
110 ROOT_URLCONF = 'bns_website.urls' | |
111 | |
112 TEMPLATE_DIRS = [ | |
113 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | |
114 # Always use forward slashes, even on Windows. | |
115 # Don't forget to use absolute paths, not relative paths. | |
116 os.path.join(PROJECT_PATH, 'templates'), | |
117 ] | |
118 | |
119 TEMPLATE_CONTEXT_PROCESSORS = [ | |
120 'django.contrib.auth.context_processors.auth', | |
121 'django.core.context_processors.debug', | |
122 'django.core.context_processors.request', | |
123 'django.core.context_processors.media', | |
124 'django.core.context_processors.static', | |
125 ] | |
126 | |
127 INSTALLED_APPS = [ | |
128 'django.contrib.auth', | |
129 'django.contrib.contenttypes', | |
130 'django.contrib.sessions', | |
131 'django.contrib.sites', | |
132 'django.contrib.messages', | |
133 'django.contrib.staticfiles', | |
134 'django.contrib.admin', | |
135 'django.contrib.admindocs', | |
136 ] | |
137 | |
138 # A sample logging configuration. The only tangible logging | |
139 # performed by this configuration is to send an email to | |
140 # the site admins on every HTTP 500 error. | |
141 # See http://docs.djangoproject.com/en/dev/topics/logging for | |
142 # more details on how to customize your logging configuration. | |
143 LOGGING = { | |
144 'version': 1, | |
145 'disable_existing_loggers': False, | |
146 'handlers': { | |
147 'mail_admins': { | |
148 'level': 'ERROR', | |
149 'class': 'django.utils.log.AdminEmailHandler' | |
150 } | |
151 }, | |
152 'loggers': { | |
153 'django.request': { | |
154 'handlers': ['mail_admins'], | |
155 'level': 'ERROR', | |
156 'propagate': True, | |
157 }, | |
158 } | |
159 } |