Sunday, November 22, 2015

Re: List of available Jinja2 global symbols

After reading a bit, it looks like only the Django Template backend can use context processors, not the Jinja2 backend. If this is true then Jinja2 isn't using any context processors  I'm wondering how the Jinja2 templates are getting the value for csrf_token and request then. I guess from the middleware. I just wish there was a list of globals that were accessible from the JInja2 templates.

On Sunday, November 22, 2015 at 6:17:59 AM UTC-6, JirkaV wrote:
Hi there, I'm not a Jinja2 user, but standard Django templates get these variables via context processors‎. Check out https://docs.djangoproject.com/en/1.8/topics/templates/#context-processors

 HTH

   Jirka

From: Patrick Spencer
Sent: neděle, 22. listopadu 2015 5:45
To: Django users
Subject: List of available Jinja2 global symbols

I'm using Django 1.8.6 with the built in JInja2 support. I spent a while trying to figure out how to pass a csrf token to a JInja2 template. After a while I realized one could just write {{ csrf_token }} in the template, without passing this value through a view, and it would just print out the token. I also realized you could reference a request object without passing it through the view i.e. {{ request.user }} returns the current user. Is there a place in the documentation with all the available global symbols one can use in a Jinja2 template?

--
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...@googlegroups.com.
To post to this group, send email to django...@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/537bd366-180e-4876-8b91-5791f8e22d44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
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/e04203a4-c3fb-46ed-82df-a2d8623ad307%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment