About Modifying Template Context Variables Globally
Template context variables can't be modified globally in context processors or middlewares, but instead you can modify the attributes of the HttpRequest
object in context processors, for example:
site_specific/views.py
1 2 3 4 5 6 7 |
|
site_specific/context_processors.py
1 2 3 4 5 6 7 |
|
templates/home.html
1 2 3 4 5 6 7 8 9 10 |
|
Tips and Tricks Programming Django 4.2 Django 3.2 Django 2.2 HTML5
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django GDPR Cookie Consent app
For Django websites that use cookies.