Skip to content

Commit b4afb87

Browse files
committed
Added new settings structure
1 parent 2219748 commit b4afb87

File tree

8 files changed

+152
-13
lines changed

8 files changed

+152
-13
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.pyc
22
db.sqlite3
3+
/tutorial/settings/local

tutorial/settings.py

-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
"""
2-
Django settings for tutorial project.
3-
4-
Generated by 'django-admin startproject' using Django 1.10.
5-
6-
For more information on this file, see
7-
https://docs.djangoproject.com/en/1.10/topics/settings/
8-
9-
For the full list of settings and their values, see
10-
https://docs.djangoproject.com/en/1.10/ref/settings/
11-
"""
12-
131
import os
142

153
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)

tutorial/settings/__init__.py

Whitespace-only changes.

tutorial/settings/base.py

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
import os
2+
3+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
4+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
5+
6+
7+
# Quick-start development settings - unsuitable for production
8+
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
9+
10+
# SECURITY WARNING: keep the secret key used in production secret!
11+
SECRET_KEY = '4blyti@u4yj$skr7e&g63f*l%#jl(xq&od-2y&qzo^rrs!_p#7'
12+
13+
# SECURITY WARNING: don't run with debug turned on in production!
14+
DEBUG = True
15+
16+
ALLOWED_HOSTS = []
17+
18+
19+
# Application definition
20+
21+
INSTALLED_APPS = [
22+
'accounts',
23+
'home',
24+
'django.contrib.admin',
25+
'django.contrib.auth',
26+
'django.contrib.contenttypes',
27+
'django.contrib.sessions',
28+
'django.contrib.messages',
29+
'django.contrib.staticfiles',
30+
]
31+
32+
MIDDLEWARE = [
33+
'django.middleware.security.SecurityMiddleware',
34+
'django.contrib.sessions.middleware.SessionMiddleware',
35+
'django.middleware.common.CommonMiddleware',
36+
'django.middleware.csrf.CsrfViewMiddleware',
37+
'django.contrib.auth.middleware.AuthenticationMiddleware',
38+
'django.contrib.messages.middleware.MessageMiddleware',
39+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
40+
'tutorial.middleware.LoginRequiredMiddleware'
41+
]
42+
43+
ROOT_URLCONF = 'tutorial.urls'
44+
45+
TEMPLATES = [
46+
{
47+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
48+
'DIRS': [],
49+
'APP_DIRS': True,
50+
'OPTIONS': {
51+
'context_processors': [
52+
'django.template.context_processors.debug',
53+
'django.template.context_processors.request',
54+
'django.contrib.auth.context_processors.auth',
55+
'django.contrib.messages.context_processors.messages',
56+
],
57+
},
58+
},
59+
]
60+
61+
WSGI_APPLICATION = 'tutorial.wsgi.application'
62+
63+
64+
# Database
65+
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
66+
67+
DATABASES = {
68+
'default': {
69+
'ENGINE': 'django.db.backends.sqlite3',
70+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
71+
}
72+
}
73+
74+
75+
# Password validation
76+
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
77+
78+
AUTH_PASSWORD_VALIDATORS = [
79+
{
80+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
81+
},
82+
{
83+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
84+
},
85+
{
86+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
87+
},
88+
{
89+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
90+
},
91+
]
92+
93+
94+
# Internationalization
95+
# https://docs.djangoproject.com/en/1.10/topics/i18n/
96+
97+
LANGUAGE_CODE = 'en-us'
98+
99+
TIME_ZONE = 'UTC'
100+
101+
USE_I18N = True
102+
103+
USE_L10N = True
104+
105+
USE_TZ = True
106+
107+
108+
# Static files (CSS, JavaScript, Images)
109+
# https://docs.djangoproject.com/en/1.10/howto/static-files/
110+
111+
STATIC_URL = '/static/'
112+
113+
MEDIA_URL = '/media/'
114+
MEDIA_ROOT = os.path.join(BASE_DIR, 'tutorial/media')
115+
116+
LOGIN_REDIRECT_URL = '/home/'
117+
118+
LOGIN_URL = '/account/login/'
119+
120+
LOGIN_EXEMPT_URLS = (
121+
r'^account/logout/$',
122+
r'^account/register/$',
123+
r'^account/reset-password/$',
124+
r'^account/reset-password/done/$',
125+
r'^account/reset-password/confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
126+
r'^account/reset-password/complete/$',
127+
)
128+
129+
EMAIL_HOST = 'localhost'
130+
EMAIL_PORT = 1025

tutorial/settings/dev.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from tutorial.settings.base import *
2+
3+
# Override base.py settings here
4+
5+
6+
7+
try:
8+
from tutorial.settings.local import *
9+
except:
10+
pass

tutorial/settings/local.py

Whitespace-only changes.

tutorial/settings/prod.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from tutorial.settings.base import *
2+
3+
# Override base.py settings here
4+
5+
6+
7+
try:
8+
from tutorial.settings.local import *
9+
except:
10+
pass

tutorial/wsgi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
from django.core.wsgi import get_wsgi_application
1313

14-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tutorial.settings")
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tutorial.settings.prod")
1515

1616
application = get_wsgi_application()

0 commit comments

Comments
 (0)