Skip to content

Commit

Permalink
Feat: Connect database variables to docker compose or env
Browse files Browse the repository at this point in the history
  • Loading branch information
SverreNystad committed Jan 4, 2024
1 parent 502e304 commit 58f49ea
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions backend/tutorai/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand Down Expand Up @@ -88,18 +89,17 @@
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'tutoraidb',
'USER': 'tutoraiuser',
'PASSWORD': 'tutoraipassword',
'HOST': 'db',
'PORT': '5432',
'OPTIONS': {'sslmode': 'prefer'}
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.getenv("DATABASE_NAME", "tutoraidb"),
"USER": os.getenv("DATABASE_USER", "tutoraiuser"),
"PASSWORD": os.getenv("DATABASE_PASSWORD", "tutoraipassword"),
"HOST": os.getenv("DATABASE_HOST", "db"),
"PORT": os.getenv("DATABASE_PORT", "5432"),
"OPTIONS": {"sslmode": "prefer"},
}
}


# Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators

Expand Down

0 comments on commit 58f49ea

Please sign in to comment.