From 44999fe93cba22c48d1c60b7559e8c3ffaa7e809 Mon Sep 17 00:00:00 2001
From: Rahmania Astrid Mochtar <rahmania.astrid@ui.ac.id>
Date: Wed, 16 Oct 2019 23:08:45 +0700
Subject: [PATCH] deploy to heroku - exercise 5

---
 .gitignore             |  1 +
 requirements.txt       |  2 ++
 superlists/settings.py | 18 +++++++++++-------
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/.gitignore b/.gitignore
index ad19f56..4288bd2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@ db.sqlite3
 __pycache__
 *.pyc
 /static
+env/
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index 059c6e3..de63f73 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,3 +2,5 @@ astroid==2.2.5
 Django==2.1.7
 selenium==3.141.0
 gunicorn==19.9.0
+psycopg2
+dj_database_url
\ No newline at end of file
diff --git a/superlists/settings.py b/superlists/settings.py
index 743a5f7..0e628fe 100644
--- a/superlists/settings.py
+++ b/superlists/settings.py
@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/2.1/ref/settings/
 """
 
 import os
+import dj_database_url
 
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -76,13 +77,12 @@ WSGI_APPLICATION = 'superlists.wsgi.application'
 
 # Database
 # https://docs.djangoproject.com/en/2.1/ref/settings/#databases
+DATABASE_URL = 'postgres://zrcgjeyohzggpw:7310e5d8c03d5e4ec62247a9bfc04a608bc4ad045c7618ee1a06109be6768a5b@ec2-23-21-160-80.compute-1.amazonaws.com:5432/d2qi0m4m9s14o6'
+db_from_env = dj_database_url.config(conn_max_age=600)
+DATABASES = {'default': dj_database_url.config(default=DATABASE_URL)}
 
-DATABASES = {
-    'default': {
-        'ENGINE': 'django.db.backends.sqlite3',
-        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
-    }
-}
+# Honor the 'X-Forwarded-Proto' header for request.is_secure()
+SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
 
 
 # Password validation
@@ -121,5 +121,9 @@ USE_TZ = True
 # Static files (CSS, JavaScript, Images)
 # https://docs.djangoproject.com/en/2.1/howto/static-files/
 
+STATIC_ROOT = 'staticfiles'
 STATIC_URL = '/static/'
-STATIC_ROOT = os.path.join(BASE_DIR, 'static')
+
+STATICFILES_DIRS = (
+    os.path.join(BASE_DIR, 'static'),
+)
-- 
GitLab