Fix database configuration

This commit is contained in:
Senad Uka
2023-07-05 20:02:18 +02:00
parent 2ba56e5852
commit 8f04fc01d5
2 changed files with 8 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
from pathlib import Path
import os
import dj_database_url
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -78,12 +79,17 @@ WSGI_APPLICATION = 'CTOAsYouGo.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = {
if 'DATABASE_URL' in os.environ:
DATABASES = {
'default': dj_database_url.config()
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
}
# Password validation