Skip to content

Commit e4217c9

Browse files
committed
Add production settings
1 parent 2a2503d commit e4217c9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tutorial/settings.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import os
1414
import dj_database_url
1515

16+
ENVIRONMENT = os.getenv('ENVIRONMENT', 'development')
17+
1618
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
1719
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1820

@@ -122,11 +124,22 @@
122124

123125
STATIC_URL = '/static/'
124126
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
125-
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
126127

127128
# Django REST Framework
128129
REST_FRAMEWORK = {
129130
'PAGE_SIZE': 10,
130131
'DEFAULT_PAGINATION_CLASS':
131132
'rest_framework.pagination.PageNumberPagination',
132133
}
134+
135+
if ENVIRONMENT == 'production':
136+
DEBUG = False
137+
SECRET_KEY = os.getenv('SECRET_KEY')
138+
SESSION_COOKIE_SECURE = True
139+
SECURE_BROWSER_XSS_FILTER = True
140+
SECURE_CONTENT_TYPE_NOSNIFF = True
141+
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
142+
SECURE_HSTS_SECONDS = 31536000
143+
SECURE_REDIRECT_EXEMPT = []
144+
SECURE_SSL_REDIRECT = True
145+
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

0 commit comments

Comments
 (0)