Add context processor for settings variables

This allows for usage of settings variables in templates, e.g

```
{% if settings.USE_ANALYTICS %}
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ settings.GOOGLE_TAG_MANAGER_ID }}" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
{% endif %}
```
This commit is contained in:
Dani Hodovic 2019-08-22 14:57:00 +02:00
parent baab918874
commit 69566f5456
No known key found for this signature in database
GPG Key ID: 15433E10A71D1221
3 changed files with 6 additions and 0 deletions

View File

@ -187,6 +187,7 @@ TEMPLATES = [
"django.template.context_processors.static",
"django.template.context_processors.tz",
"django.contrib.messages.context_processors.messages",
"{{ cookiecutter.project_slug }}.utils.context_processors.settings_context",
],
},
}

View File

@ -0,0 +1,5 @@
from django.conf import settings
def settings_context(_request):
return {"settings": settings}