Commit 2d980b2c authored by impfundev's avatar impfundev

fix: adding load_dotenv to manage environment variable

parent 2d1c1398
DEBUG=1
SECRET_KEY=foo
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
\ No newline at end of file
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": "library_app_dev",
"USER": "root",
"PASSWORD": "ilhammaulana13",
"HOST": "localhost",
"PORT": "3306",
}
}
LIST_HOST = [
"localhost",
"127.0.0.1",
"192.168.2.252",
"library_app.ilhammaulana.me",
]
...@@ -10,8 +10,11 @@ For the full list of settings and their values, see ...@@ -10,8 +10,11 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.0/ref/settings/ https://docs.djangoproject.com/en/5.0/ref/settings/
""" """
import os
from pathlib import Path from pathlib import Path
from .constants import DATABASES, LIST_HOST from dotenv import load_dotenv
load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
...@@ -21,11 +24,16 @@ BASE_DIR = Path(__file__).resolve().parent.parent ...@@ -21,11 +24,16 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "PkJtZr9Ctg7/Rg2PraJTxlW3w0szR8pi0UKylLc/5+lGGt+Z8zIctlRrRcgcC40ajeBLHp9227fMHAFx8b6Rsg==" SECRET_KEY = os.environ.get("SECRET_KEY")
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False DEBUG = False
ALLOWED_HOSTS = LIST_HOST ALLOWED_HOSTS = [
"localhost",
"127.0.0.1",
os.environ.get("IP_HOST"),
"library_app.ilhammaulana.me",
]
# Application definition # Application definition
...@@ -94,7 +102,16 @@ WSGI_APPLICATION = "config.wsgi.application" ...@@ -94,7 +102,16 @@ WSGI_APPLICATION = "config.wsgi.application"
# } # }
# } # }
DATABASES = DATABASES DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": os.environ.get("DB_NAME"),
"USER": os.environ.get("DB_USER"),
"PASSWORD": os.environ.get("DB_PASSWORD"),
"HOST": os.environ.get("DB_HOST"),
"PORT": os.environ.get("DB_PORT"),
}
}
# Password validation # Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
......
Markdown is supported
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