diff --git a/.gitignore b/.gitignore index 4ea3281..c2ceb3f 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ db.sqlite3-journal # OS-specific files .DS_Store Thumbs.db + +# Database configuration +config/database.ini diff --git a/config/database.ini b/config/database.ini new file mode 100644 index 0000000..9c72fa5 --- /dev/null +++ b/config/database.ini @@ -0,0 +1,6 @@ +[postgresql] +host=barad-dur.lan.mgk.one +database=leadsdb +user=melkor +password=Th3leetnis!leadsdb +port=5433 diff --git a/leadsdb/settings.py b/leadsdb/settings.py index c957f40..e2a5ba7 100644 --- a/leadsdb/settings.py +++ b/leadsdb/settings.py @@ -12,10 +12,15 @@ https://docs.djangoproject.com/en/4.2/ref/settings/ import os from pathlib import Path +import configparser # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent +# Read database configuration +config = configparser.ConfigParser() +config.read(os.path.join(BASE_DIR, 'config', 'database.ini')) + # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ @@ -78,11 +83,11 @@ WSGI_APPLICATION = 'leadsdb.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', - 'NAME': 'leadsdb', - 'USER': 'melkor', - 'PASSWORD': 'Th3leetnis!leadsdb', - 'HOST': 'barad-dur.lan.mgk.one', - 'PORT': '5433', + 'NAME': config['postgresql']['database'], + 'USER': config['postgresql']['user'], + 'PASSWORD': config['postgresql']['password'], + 'HOST': config['postgresql']['host'], + 'PORT': config['postgresql']['port'], } }