Fakultas Ilmu Komputer UI

Commit 7edee322 authored by Fakhira Devina's avatar Fakhira Devina
Browse files

Merge branch 'dev-ariq' into 'PBI-2-deployment'

[REFACTOR] removed hardcoded variables, added python-dotenv

See merge request !4
parents a2c94feb b072b73e
Pipeline #64458 failed with stages
in 11 minutes and 47 seconds
......@@ -11,12 +11,13 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
from datetime import timedelta
import dj_database_url
from dotenv import load_dotenv
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
load_dotenv(os.path.join(BASE_DIR, '.env'))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
......@@ -26,11 +27,10 @@ SECRET_KEY = os.getenv("SECRET_KEY", 'akua')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = FALSE
DEBUG = os.getenv('DEBUG') == 'True'
ALLOWED_HOSTS = ['localhost', '127.0.0.1', '10.119.105.26', 'bisago.cs.ui.ac.id']
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', 'localhost').strip(';').split(';')
#ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
......@@ -96,19 +96,21 @@ WSGI_APPLICATION = 'pplbackend.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ.get('DB_NAME', ''),
'USER': os.environ.get('DB_USER', ''),
'PASSWORD': os.environ.get('DB_PASSWORD', ''),
'HOST': os.environ.get('DB_HOST', 'localhost'),
'PORT': os.environ.get('DB_PORT', '5432'),
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
#if os.environ.get("DATABASE_URL"):
# DATABASES['default'] = dj_database_url.config()
# custom database host, overriding the default
if os.getenv('DB_HOST') is not None:
DATABASES['default'] = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.getenv('DB_NAME'),
'USER': os.getenv('DB_USER'),
'PASSWORD': os.getenv('DB_PASSWORD'),
'HOST': os.getenv('DB_HOST'),
'PORT': os.getenv('DB_PORT'),
}
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
......
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