In our codebase, we pass in some settings and other constants via a
context processor, which never looks at the request object.
It would be convenient for those constants to be used in all templates, as
apposed to templates with requests only.
I see 2 possible approaches to adding this functionality:
- Add a constant_processor, however this wrongly limits it to constants.
- make the request argument optional going forward, and use arg
inspections to conditionally context processors for a period.
Using `some_context_processor(request=None)` would show the processor
supports request objects not being set.
--
Ticket URL: <https://code.djangoproject.com/ticket/27570>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Aymeric Augustin):
Quoting myself or #django-dev:
> I would be more happy to support an option to add globals to Django
templates — that could be a simple configuration option — than to start
executing request context processors without a request
> for your own projet, you can create a custom template backend that
inherits the Django template backend, overrides render, and adds your
globals to the context before calling the parent
--
Ticket URL: <https://code.djangoproject.com/ticket/27570#comment:1>
Comment (by Tim Graham):
Is adding another way to do this better than using a template tag? You
could add the tag to `TEMPLATES['OPTIONS']['builtins']` to avoid `{% load
... %}` in the template.
--
Ticket URL: <https://code.djangoproject.com/ticket/27570#comment:2>
* status: new => closed
* resolution: => wontfix
Comment:
Feel free to reopen with an explanation of why the solution I proposed
isn't sufficient.
--
Ticket URL: <https://code.djangoproject.com/ticket/27570#comment:3>