Fakultas Ilmu Komputer UI

Commit bc3614a8 authored by Rayza Arasj Mahardhika's avatar Rayza Arasj Mahardhika
Browse files

setup postgre

parent 01fa3ce8
......@@ -3,3 +3,4 @@ __pycache__
*.pyc
.vscode
/staticfiles
db.sqlite3
\ No newline at end of file
......@@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/2.2/ref/settings/
import os
import django_heroku
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__)))
......@@ -93,8 +94,12 @@ WSGI_APPLICATION = 'superlists.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ.get('DB_NAME', ''),
'USER': os.environ.get('DB_USER', ''),
'PASSWORD': os.environ.get('DB_PASS', ''),
'HOST': 'localhost',
'PORT': '5432',
}
}
......@@ -138,4 +143,7 @@ USE_TZ = True
STATIC_URL = '/static/'
STATIC_ROOT = os.path.abspath(os.path.join(BASE_DIR, 'static'))
django_heroku.settings(locals())
\ No newline at end of file
if os.environ.get('ENV', 'production') == 'production':
django_heroku.settings(locals())
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment