Monday, November 23, 2015

Re: List of available Jinja2 global symbols

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQIcBAEBCAAGBQJWU5SpAAoJEC0ft5FqUuEh/YgQAK5oxD0DA4a55BjILfU34nQf
2hG5Dj2UC7rDqSzyxC7EuIUcT8Lmxggq78DPFh2Moov45euDjHrACcZKAvonNzDS
pOekOSkUL/3fnKm9i5fF5CbaQW+d9gh0OhUDgnfOFMTFFP4bNoAUt4zBlgjVdC2G
+fywGpa69meekGWhosYPi6zzddDqtUvM7lrEAR9HgQ0H8gr6F/5ojedgmQOzMOBM
qAyRW/Zsi10J1DAfgXe0gWo5u6164NbA2x1Vuc5YHXh5hX98IpBTJjY7Rk8z8MBi
ZH+YDr8Bg2Nv1sYKpf7Ghjv/GvhmNpknT06Z094uw2reD5e7h2CXxXGHUl7ciLRe
Jace1C1H8KICErUB0n0NGvPMUjpeg2ieqZvrA8HwOuYWXfU1oOIHg0XrHc+9x7gz
jvYg6MfXV/QYvfpC6r0chfqKcvem5a4kbCHpZEjw9HoafYL7lGiHu5zTYT7SJZxX
oA6nfTk+wCc6YlSKAkJsuPw13evzGs0Iu+Uro+uepo9Tg2fTSwsLPZf4qi6FZJuw
I9Zri2XO+J70gEklT2Ou66/7iiY7CbPkIqSNS64+ZKLB9LNSZ82eDcpd9X2m/OcK
pVivl9herbCq381EPySa1Im5AsUpyqB79dazEqbWdlNxQGjpq6wGVbkAjl1stqKe
B1r0nYIDYLMSo1e/uLW9
=8EmG
-----END PGP SIGNATURE-----
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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/565394A5.4050104%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment