Skip to content

Commit

Permalink
Add custom context processor
Browse files Browse the repository at this point in the history
This context processor actually belongs within ctlsettings I think,
since these variables are defined here, rather than the
django-stagingcontext package.
  • Loading branch information
nikolas committed Oct 10, 2024
1 parent d38253c commit d4f0949
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 11 additions & 0 deletions ctlsettings/context_processors.py
Original file line number Diff line number Diff line change
@@ -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'),
}
1 change: 1 addition & 0 deletions ctlsettings/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
},
Expand Down

0 comments on commit d4f0949

Please sign in to comment.