From 5136122ed96e4f0e984d9def742dd3625de015a1 Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Sat, 26 Apr 2025 23:21:23 +0200 Subject: [PATCH] Make boolean settings case insensitive Having to use the Python syntax when it comes to case sensitivity for booleans in environment variables can be unexpected and doesn't really provide any benefit. This patch makes all boolean settings case-insensitive. This means that, for example, both `True` and `true` evaluate to `True` in Python. This fixes #559 --- backend/server/main/settings.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/server/main/settings.py b/backend/server/main/settings.py index 406e37a..c9af870 100644 --- a/backend/server/main/settings.py +++ b/backend/server/main/settings.py @@ -27,7 +27,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(__file__)) SECRET_KEY = getenv('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = getenv('DEBUG', 'True') == 'True' +DEBUG = getenv('DEBUG', 'true').lower() == 'true' # ALLOWED_HOSTS = [ # 'localhost', @@ -201,7 +201,7 @@ TEMPLATES = [ # Authentication settings -DISABLE_REGISTRATION = getenv('DISABLE_REGISTRATION', 'False') == 'True' +DISABLE_REGISTRATION = getenv('DISABLE_REGISTRATION', 'false').lower() == 'true' DISABLE_REGISTRATION_MESSAGE = getenv('DISABLE_REGISTRATION_MESSAGE', 'Registration is disabled. Please contact the administrator if you need an account.') AUTH_USER_MODEL = 'users.CustomUser' @@ -242,9 +242,9 @@ if getenv('EMAIL_BACKEND', 'console') == 'console': else: EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = getenv('EMAIL_HOST') - EMAIL_USE_TLS = getenv('EMAIL_USE_TLS', 'True') == 'True' + EMAIL_USE_TLS = getenv('EMAIL_USE_TLS', 'true').lower() == 'true' EMAIL_PORT = getenv('EMAIL_PORT', 587) - EMAIL_USE_SSL = getenv('EMAIL_USE_SSL', 'False') == 'True' + EMAIL_USE_SSL = getenv('EMAIL_USE_SSL', 'false').lower() == 'true' EMAIL_HOST_USER = getenv('EMAIL_HOST_USER') EMAIL_HOST_PASSWORD = getenv('EMAIL_HOST_PASSWORD') DEFAULT_FROM_EMAIL = getenv('DEFAULT_FROM_EMAIL') @@ -312,4 +312,4 @@ LOGGING = { # ADVENTURELOG_CDN_URL = getenv('ADVENTURELOG_CDN_URL', 'https://cdn.adventurelog.app') # https://github.com/dr5hn/countries-states-cities-database/tags -COUNTRY_REGION_JSON_VERSION = 'v2.5' \ No newline at end of file +COUNTRY_REGION_JSON_VERSION = 'v2.5'