From 46e9e0fcfa3df650a4b62254120d84c6abc714dd Mon Sep 17 00:00:00 2001 From: Johannes Erwerle Date: Sat, 18 Apr 2026 17:51:53 +0200 Subject: [PATCH] moved SECRET_KEY and DEBUG variables from settings to configuration. --- README.md | 8 ++++++++ .../community_backup/example_configuration.py | 6 ++++++ community_backup/community_backup/settings.py | 9 ++++----- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f6af251..6bf868d 100644 --- a/README.md +++ b/README.md @@ -112,3 +112,11 @@ DATABASES = { } } ``` + +### SECRET_KEY + +The secret key used by django for session cookies and other things. + +### DEBUG + +Django debug setting. diff --git a/community_backup/community_backup/example_configuration.py b/community_backup/community_backup/example_configuration.py index fec60ea..cf06f1c 100644 --- a/community_backup/community_backup/example_configuration.py +++ b/community_backup/community_backup/example_configuration.py @@ -13,3 +13,9 @@ DATABASES = { "NAME": "/path/to/the/db.sqlite3", } } + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = "change me!" + +# SECURITY WARNING: don't run with debug turned on in production! +# DEBUG = True diff --git a/community_backup/community_backup/settings.py b/community_backup/community_backup/settings.py index 47514da..b8c735f 100644 --- a/community_backup/community_backup/settings.py +++ b/community_backup/community_backup/settings.py @@ -20,11 +20,6 @@ BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/ -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = "django-insecure-_53=1gp5m=j+ienpcguini#xczk^d+&jx*#@z+2837+_-0=+$z" - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True ALLOWED_HOSTS = [ "*", @@ -124,6 +119,7 @@ try: config_module = "community_backup.configuration" module = import_module(config_module) + assert module.SECRET_KEY, "The Django SECRET is required." assert module.BACKUP_USER, "The BACKUP_USER setting is required." assert module.BACKUP_REPO_HOST, "The BACKUP_REPO_HOST setting is required." assert module.BACKUP_HOME_DIR, "The BACKUP_HOME_DIR setting is required." @@ -142,3 +138,6 @@ BACKUP_HOME_DIR = module.BACKUP_HOME_DIR BACKUP_BORG_DIR = module.BACKUP_BORG_DIR BACKUP_AUTHORIZED_KEYS = module.BACKUP_AUTHORIZED_KEYS DATABASES = module.DATABASES +SECRET_KEY = module.SECRET_KEY + +DEBUG = getattr(module, "DEBUG", False)