Skip to content

Commit b5a9940

Browse files
author
Massimiliano Pippi
committed
settings package
1 parent 37c6459 commit b5a9940

File tree

4 files changed

+197
-0
lines changed

4 files changed

+197
-0
lines changed

example/example/settings/__init__.py

Whitespace-only changes.

example/example/settings/base.py

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# Django settings for example project.
2+
import os
3+
from os.path import join, abspath, dirname
4+
5+
import django.conf.global_settings as DEFAULT_SETTINGS
6+
7+
# Root directory of our project
8+
PROJECT_ROOT = abspath(join(abspath(dirname(__file__)), "..",))
9+
10+
DEBUG = os.environ.get('DJANGO_DEBUG', True)
11+
TEMPLATE_DEBUG = DEBUG
12+
13+
ADMINS = (
14+
# ('Your Name', '[email protected]'),
15+
)
16+
17+
MANAGERS = ADMINS
18+
19+
# Hosts/domain names that are valid for this site; required if DEBUG is False
20+
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
21+
ALLOWED_HOSTS = []
22+
23+
# Local time zone for this installation. Choices can be found here:
24+
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
25+
# although not all choices may be available on all operating systems.
26+
# In a Windows environment this must be set to your system time zone.
27+
TIME_ZONE = 'America/Chicago'
28+
29+
# Language code for this installation. All choices can be found here:
30+
# http://www.i18nguy.com/unicode/language-identifiers.html
31+
LANGUAGE_CODE = 'en-us'
32+
33+
SITE_ID = 1
34+
35+
# If you set this to False, Django will make some optimizations so as not
36+
# to load the internationalization machinery.
37+
USE_I18N = True
38+
39+
# If you set this to False, Django will not format dates, numbers and
40+
# calendars according to the current locale.
41+
USE_L10N = True
42+
43+
# If you set this to False, Django will not use timezone-aware datetimes.
44+
USE_TZ = True
45+
46+
# Absolute filesystem path to the directory that will hold user-uploaded files.
47+
# Example: "/var/www/example.com/media/"
48+
MEDIA_ROOT = join(PROJECT_ROOT, "media")
49+
50+
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
51+
# trailing slash.
52+
# Examples: "http://example.com/media/", "http://media.example.com/"
53+
MEDIA_URL = '/media/'
54+
55+
# Absolute path to the directory static files should be collected to.
56+
# Don't put anything in this directory yourself; store your static files
57+
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
58+
# Example: "/var/www/example.com/static/"
59+
STATIC_ROOT = join(PROJECT_ROOT, "static")
60+
61+
# URL prefix for static files.
62+
# Example: "http://example.com/static/", "http://static.example.com/"
63+
STATIC_URL = '/static/'
64+
65+
# Additional locations of static files
66+
STATICFILES_DIRS = (
67+
# Put strings here, like "/home/html/static" or "C:/www/django/static".
68+
# Always use forward slashes, even on Windows.
69+
# Don't forget to use absolute paths, not relative paths.
70+
)
71+
72+
# List of finder classes that know how to find static files in
73+
# various locations.
74+
STATICFILES_FINDERS = (
75+
'django.contrib.staticfiles.finders.FileSystemFinder',
76+
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
77+
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
78+
)
79+
80+
# Make this unique, and don't share it with anybody.
81+
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'do_not_use_this_key')
82+
83+
# List of callables that know how to import templates from various sources.
84+
TEMPLATE_LOADERS = (
85+
'django.template.loaders.filesystem.Loader',
86+
'django.template.loaders.app_directories.Loader',
87+
# 'django.template.loaders.eggs.Loader',
88+
)
89+
90+
MIDDLEWARE_CLASSES = (
91+
'django.middleware.common.CommonMiddleware',
92+
'django.contrib.sessions.middleware.SessionMiddleware',
93+
'django.middleware.csrf.CsrfViewMiddleware',
94+
'django.contrib.auth.middleware.AuthenticationMiddleware',
95+
'django.contrib.messages.middleware.MessageMiddleware',
96+
'example.middleware.XsSharingMiddleware',
97+
# Uncomment the next line for simple clickjacking protection:
98+
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
99+
)
100+
101+
TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_SETTINGS.TEMPLATE_CONTEXT_PROCESSORS + (
102+
"django.core.context_processors.request",
103+
)
104+
105+
ROOT_URLCONF = 'example.urls'
106+
107+
# Python dotted path to the WSGI application used by Django's runserver.
108+
WSGI_APPLICATION = 'example.wsgi.application'
109+
110+
TEMPLATE_DIRS = (
111+
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
112+
# Always use forward slashes, even on Windows.
113+
# Don't forget to use absolute paths, not relative paths.
114+
os.path.join(os.path.dirname(os.path.realpath(__file__)), 'templates'),
115+
)
116+
117+
INSTALLED_APPS = (
118+
'django.contrib.auth',
119+
'django.contrib.contenttypes',
120+
'django.contrib.sessions',
121+
'django.contrib.sites',
122+
'django.contrib.messages',
123+
'django.contrib.staticfiles',
124+
'django.contrib.admin',
125+
'oauth2_provider',
126+
'south',
127+
'example',
128+
)
129+
130+
# A sample logging configuration. The only tangible logging
131+
# performed by this configuration is to send an email to
132+
# the site admins on every HTTP 500 error when DEBUG=False.
133+
# See http://docs.djangoproject.com/en/dev/topics/logging for
134+
# more details on how to customize your logging configuration.
135+
LOGGING = {
136+
'version': 1,
137+
'disable_existing_loggers': False,
138+
'formatters': {
139+
'verbose': {
140+
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
141+
},
142+
'simple': {
143+
'format': '%(levelname)s %(message)s'
144+
},
145+
},
146+
'filters': {
147+
'require_debug_false': {
148+
'()': 'django.utils.log.RequireDebugFalse'
149+
}
150+
},
151+
'handlers': {
152+
'mail_admins': {
153+
'level': 'ERROR',
154+
'filters': ['require_debug_false'],
155+
'class': 'django.utils.log.AdminEmailHandler'
156+
},
157+
'console': {
158+
'level': 'DEBUG',
159+
'class': 'logging.StreamHandler',
160+
'formatter': 'simple'
161+
}
162+
},
163+
'loggers': {
164+
'django.request': {
165+
'handlers': ['mail_admins'],
166+
'level': 'ERROR',
167+
'propagate': True,
168+
},
169+
'oauth2_provider': {
170+
'handlers': ['console'],
171+
'level': 'DEBUG',
172+
'propagate': True,
173+
},
174+
}
175+
}
176+
177+
OAUTH2_PROVIDER = {
178+
'SCOPES': {'example': 'This is an example scope'},
179+
'APPLICATION_MODEL': 'example.MyApplication'
180+
}
181+
182+
from django.core.urlresolvers import reverse_lazy
183+
184+
LOGIN_REDIRECT_URL = reverse_lazy('home')

example/example/settings/dev.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from .base import *
2+
3+
DATABASES = {
4+
'default': {
5+
'ENGINE': 'django.db.backends.sqlite3',
6+
'NAME': 'example.sqlite',
7+
}
8+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .base import *
2+
3+
# Parse database configuration from $DATABASE_URL
4+
import dj_database_url
5+
DATABASES['default'] = dj_database_url.config()

0 commit comments

Comments
 (0)