On 11/22/2015 06:21 PM, Patrick Spencer wrote:
> I see what you mean about not being about to have a global list of
> symbols because everything is subject to change. But it would be nice to
> have a default list of symbols available depending on the default
> initial setup.
Yes, the default additions to the Jinja2 template context should be
documented, and (as far as I can tell) are not. I've filed
https://code.djangoproject.com/ticket/25804 for this.
> I think the csrf_token and request token are available in the
> django.templates.backend.jinja2 module, as knbk pointed out.
>
> I still don't think the jinja template processor is able to load
> context_processors. Right now my messages aren't working and I think
> this is the reason.
That's right, the Jinja2 backend doesn't support context processors.
There's an accepted ticket for it
(
https://code.djangoproject.com/ticket/24694) and I have an
implementation floating around, just need to polish it up, integrate it
with Django, and add tests and docs.
> Also, I have django debug bar but when I load a jinja2 template with it
> it says that no templates have been loaded and I can't see any context
> processors. I think this is a bug.
Yes, I believe that the debug-toolbar's support for detecting rendered
templates is DTL-specific (it predates Django's Jinja2 support by quite
a few years). Really this is an enhancement request for
django-debug-toolbar, though it may require better debug hooks in the
Django template rendering system so DDT can hook in at the generic
template-rendering layer rather than the DTL-engine layer.
> Does anyone have an idea about how to tell if django is actually loading
> the context_processors when it loads a jinja template. Also, does anyone
> have an idea how to make messages work with jinja templates?
The simplest solution for now may be to add context-processor support to
the Jinja2 backend, which can be done without too much difficulty by
subclassing it.
Carl