Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
library-app-django
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ilham Maulana
library-app-django
Commits
2d980b2c
Commit
2d980b2c
authored
Aug 12, 2024
by
impfundev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: adding load_dotenv to manage environment variable
parent
2d1c1398
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
24 deletions
+21
-24
.env.dev
.env.dev
+0
-3
constants.py
config/constants.py
+0
-17
settings.py
config/settings.py
+21
-4
requirements.txt
requirements.txt
+0
-0
No files found.
.env.dev
deleted
100644 → 0
View file @
2d1c1398
DEBUG=1
SECRET_KEY=foo
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
\ No newline at end of file
config/constants.py
deleted
100644 → 0
View file @
2d1c1398
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"
,
]
config/settings.py
View file @
2d980b2c
...
@@ -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
...
...
requirements.txt
View file @
2d980b2c
B
asgiref
==3.8.1
B
asgiref
==3.8.1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment