From a01040ebbcec467f5e429be23eb0e2fb2785f0cb Mon Sep 17 00:00:00 2001 From: sosokker Date: Sat, 18 Nov 2023 16:21:24 +0700 Subject: [PATCH] Externalize the important data / Connect to PostgreSQL --- core/settings.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/core/settings.py b/core/settings.py index e1ce06c..f524065 100644 --- a/core/settings.py +++ b/core/settings.py @@ -12,20 +12,17 @@ https://docs.djangoproject.com/en/4.2/ref/settings/ from pathlib import Path +from decouple import config, Csv + # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ - # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-n0h_4l&s5f%vix8%fa@s@4746*2(gmjh(7-2mc_!wd+_m(zu96' - # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True -ALLOWED_HOSTS = [] +SECRET_KEY = config('SECRET_KEY', default='fake-key-j5&66&8@b-!3tbq!=w6-dypl($_0zzoi*ilxd1*&$_6s-59il5') +DEBUG = config('DEBUG', default=False, cast=bool) +ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='*', cast=Csv()) # Application definition @@ -75,8 +72,12 @@ WSGI_APPLICATION = 'core.wsgi.application' DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': config('DB_NAME', default='github_actions'), + 'USER': config('DB_USER', default='postgres'), + 'PASSWORD': config('DB_PASSWORD', default='postgres'), + 'HOST': config('DB_HOST', default='127.0.0.1'), + 'PORT': config('DB_PORT', default='5432'), } }