From eb343a7a9a87bbde1a32e07b8eea089364cc6e5a Mon Sep 17 00:00:00 2001 From: codylovell Date: Sun, 12 Nov 2017 05:23:39 -0500 Subject: [PATCH] Set-up settings and static files for Heroku deployment. --- learning_log/settings.py | 20 ++++++++++++++++++++ learning_log/wsgi.py | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/learning_log/settings.py b/learning_log/settings.py index bd3bb5b..cb371fd 100644 --- a/learning_log/settings.py +++ b/learning_log/settings.py @@ -132,3 +132,23 @@ BOOTSTRAP3 = { 'include_jquery': True } + +#heroku settings +cwd = os.getcwd() +if cwd == '/app' or cwd[:4] == '/tmp': + import dj_database_url + DATABASES = { + 'default': dj_database_url.config(default='postgres://localhost') + } + #Homor the 'X-Forawarded-Proto' headre for request.is_secure(). + SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') + + #Allow all host headers. + ALLOWED_HOSTS = ['*'] + + #static asset configuration + BASE_DIR = os.path.dirname(os.path.abspath(__file__)) + STATIC_ROOT = 'staticfiles' + STATICFILES_DIR = ( + os.path.join(BASE_DIR, 'static') + ) diff --git a/learning_log/wsgi.py b/learning_log/wsgi.py index ae515c1..10f2b8f 100644 --- a/learning_log/wsgi.py +++ b/learning_log/wsgi.py @@ -10,7 +10,8 @@ import os from django.core.wsgi import get_wsgi_application +from dj_static import Cling os.environ.setdefault("DJANGO_SETTINGS_MODULE", "learning_log.settings") -application = get_wsgi_application() +application = Cling(get_wsgi_application()) \ No newline at end of file