Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Sep 27, 2024
1 parent 1901021 commit ac4141c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 33 deletions.
41 changes: 10 additions & 31 deletions codeforlife/settings/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,17 @@
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases


def get_databases( # pragma: no cover
name: str = SERVICE_NAME,
host: str = "localhost",
port: int = 5432,
user: str = "root",
password: str = "password",
):
"""Get the databases for the Django project.
Args:
name: The name of the database.
host: The network the database is exposed on.
port: The port of the server the database is exposed on.
user: A registered user on the database server.
password: The password of the database server.
Returns:
The databases for the django project.
"""
return {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.getenv("DB_NAME", name),
"HOST": os.getenv("DB_HOST", host),
"PORT": int(os.getenv("DB_PORT", port)),
"USER": os.getenv("DB_USER", user),
"PASSWORD": os.getenv("DB_PASSWORD", password),
"ATOMIC_REQUESTS": True,
}
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.getenv("DB_NAME", SERVICE_NAME),
"HOST": os.getenv("DB_HOST", "localhost"),
"PORT": int(os.getenv("DB_PORT", "5432")),
"USER": os.getenv("DB_USER", "root"),
"PASSWORD": os.getenv("DB_PASSWORD", "password"),
"ATOMIC_REQUESTS": True,
}

}

# Application definition

Expand Down
2 changes: 0 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

ROOT_URLCONF = "codeforlife.user.urls"

DATABASES = get_databases()

if __name__ == "__main__":
import os
import sys
Expand Down

0 comments on commit ac4141c

Please sign in to comment.