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

Commit e5f3444

Browse files
committed
Merge pull request #320 from goranche/split-server-env
Added a separate settings_production.py file
2 parents fea432b + 1d1b90b commit e5f3444

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

codeweekeu/settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import sys
6+
import os
67
from os.path import abspath, basename, dirname, join, normpath
78
########## PATH CONFIGURATION
89
# Absolute filesystem path to this Django project directory.
@@ -547,3 +548,8 @@
547548
from settings_local import *
548549
except ImportError, e:
549550
pass
551+
552+
# if we're running on the server, use server specific settings
553+
ENVIRONMENT = os.getenv('ENVIRONMENT', 'development')
554+
if ENVIRONMENT == 'production':
555+
from settings_production import *

codeweekeu/settings_production.py

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

0 commit comments

Comments
 (0)