Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Commit c2d4170

Browse files
committed
Added a separate settings_production.py file that gets imported if env variable ENVIRONMENT is set to production
1 parent 4bdcc97 commit c2d4170

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

codeweekeu/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,3 +547,7 @@
547547
from settings_local import *
548548
except ImportError, e:
549549
pass
550+
551+
# if we're running on the server, use server specific settings
552+
if os.environ['ENVIRONMENT'] == 'production':
553+
from settings_production import *

codeweekeu/settings_production.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from .settings import *
2+
import dj_database_url
3+
import os
4+
5+
DEBUG = False
6+
7+
dbconfig = dj_database_url.config()
8+
if dbconfig:
9+
DATABASES['default'] = dbconfig
10+
else:
11+
del DATABASES['default']
12+
13+
SECRET_KEY = os.environ['SECRET_KEY']
14+
15+
STATIC_URL = '/static/'
16+
STATIC_ROOT = join(DJANGO_ROOT, 'staticfiles')
17+
STATICFILES_DIRS = (
18+
os.path.join(DJANGO_ROOT, 'static'),
19+
)
20+
21+
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
22+
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
23+
24+
# Allow all host headers
25+
ALLOWED_HOSTS = ['*']
26+
27+
# S3 Storage settings
28+
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
29+
# use http instead of https
30+
AWS_S3_SECURE_URLS = False
31+
# don't add complex authentication-related query parameters for requests
32+
AWS_QUERYSTRING_AUTH = False
33+
# Read secret data for social logins
34+
AWS_S3_ACCESS_KEY_ID = os.environ['AWS_S3_KEY']
35+
AWS_S3_SECRET_ACCESS_KEY = os.environ['AWS_S3_SECRET']
36+
AWS_STORAGE_BUCKET_NAME = os.environ['AWS_BUCKET']
37+
38+
# URL that handles the media served from MEDIA_ROOT.
39+
MEDIA_URL = 'http://' + AWS_STORAGE_BUCKET_NAME + '.s3.amazonaws.com/'
40+
41+
# Get secret data for social logins
42+
SOCIAL_AUTH_GITHUB_KEY = os.environ['GITHUB_KEY']
43+
SOCIAL_AUTH_GITHUB_SECRET = os.environ['GITHUB_SECRET']
44+
SOCIAL_AUTH_FACEBOOK_KEY = os.environ['FACEBOOK_KEY']
45+
SOCIAL_AUTH_FACEBOOK_SECRET = os.environ['FACEBOOK_SECRET']
46+
SOCIAL_AUTH_TWITTER_KEY = os.environ['TWITTER_KEY']
47+
SOCIAL_AUTH_TWITTER_SECRET = os.environ['TWITTER_SECRET']

0 commit comments

Comments
 (0)