diff --git a/CHANGES.txt b/CHANGES.txt index 80072cb..77ecf89 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,8 @@ +0.3.7 +==================== +* Added a custom context processor to make settings available in + templates. + 0.3.6 (2024-10-09) ==================== * Added ENVIRONMENT django setting, denoting either 'staging' or diff --git a/ctlsettings/context_processors.py b/ctlsettings/context_processors.py new file mode 100644 index 0000000..607b8ac --- /dev/null +++ b/ctlsettings/context_processors.py @@ -0,0 +1,11 @@ +from django.conf import settings + + +def env(request): + """ + Environment variables from settings for use in templates. + """ + return { + 'STAGING_ENV': getattr(settings, 'STAGING_ENV', False), + 'ENVIRONMENT': getattr(settings, 'ENVIRONMENT', 'development'), + } diff --git a/ctlsettings/shared.py b/ctlsettings/shared.py index 3ca3986..bf426fd 100644 --- a/ctlsettings/shared.py +++ b/ctlsettings/shared.py @@ -125,6 +125,7 @@ def common(**kwargs): 'django.template.context_processors.request', 'django.contrib.messages.context_processors.messages', 'stagingcontext.staging_processor', + 'ctlsettings.context_processors.env', 'gacontext.ga_processor', ], },