From 5837d0d86c7b6fceee7e00e0c2e4df405e4f50b0 Mon Sep 17 00:00:00 2001 From: bronsen Date: Wed, 12 Mar 2025 18:16:13 +0100 Subject: [PATCH] [django] configure settings via django-environ django-environ reads from a file `.env` which is not under version control. Perhaps we should add a `.env.dist` or similar. --- config/settings.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/config/settings.py b/config/settings.py index 717b95b..e561c85 100644 --- a/config/settings.py +++ b/config/settings.py @@ -10,20 +10,23 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/5.1/ref/settings/ """ +import environ +import os from pathlib import Path -# Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent +env = environ.Env(DEBUG=(bool, False)) +environ.Env.read_env(BASE_DIR / ".env") # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = "django-insecure-x=%#_wxu0h=d*m#seui9+mjh3vu7of8+4+gpwj@556$un0r1%$" +SECRET_KEY = env("SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = env("DEBUG") ALLOWED_HOSTS = [] @@ -74,10 +77,7 @@ WSGI_APPLICATION = "config.wsgi.application" # https://docs.djangoproject.com/en/5.1/ref/settings/#databases DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": BASE_DIR / "db.sqlite3", - } + "default": env.db(), }