[Django] #26596: Document {{ csrf_input }} in Jinja2 templates

28 views
Skip to first unread message

Django

unread,
May 8, 2016, 11:45:42 AM5/8/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-----------------------------------------+------------------------
Reporter: aaugustin | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-----------------------------------------+------------------------
It's the equivalent of {% csrf_token %} in Django templates.

It appears that I forgot to document it.

--
Ticket URL: <https://code.djangoproject.com/ticket/26596>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 9, 2016, 6:58:10 AM5/9/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+--------------------------------------

Reporter: aaugustin | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by timgraham):

There's a mention in the
[https://docs.djangoproject.com/en/dev/topics/templates/#django.template.backends.jinja2.Jinja2
Jinja2 backend] docs. Did you miss it or have another place in mind?

--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:1>

Django

unread,
May 9, 2016, 7:05:36 AM5/9/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+--------------------------------------

Reporter: aaugustin | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by aaugustin):

I saw that mention but I don't think it's sufficiently explicit about how
to use that variable.

We should say that:

- {% csrf_token %} in Django templates translates to {{ csrf_input }} in
Jinja2 templates
- {{ csrf_token }} works identically in Django templates and in Jinja2
templates

--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:2>

Django

unread,
May 9, 2016, 7:59:31 AM5/9/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+------------------------------------

Reporter: aaugustin | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:3>

Django

unread,
May 10, 2016, 3:06:17 PM5/10/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+-------------------------------------
Reporter: aaugustin | Owner: betojulio
Type: Bug | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by betojulio):

* cc: betojulio@… (added)
* owner: nobody => betojulio
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:4>

Django

unread,
May 10, 2016, 3:54:18 PM5/10/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+-------------------------------------
Reporter: aaugustin | Owner: betojulio
Type: Bug | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by betojulio):

* Attachment "26596.diff" added.

diff file

Django

unread,
May 10, 2016, 3:55:54 PM5/10/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+-------------------------------------
Reporter: aaugustin | Owner: betojulio
Type: Bug | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------

Comment (by betojulio):

Hi I just uploaded a diff file. Are this the changes needed?
Thanks

--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:5>

Django

unread,
May 10, 2016, 4:42:32 PM5/10/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+-------------------------------------
Reporter: aaugustin | Owner: betojulio
Type: Bug | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------

Comment (by aaugustin):

I believe this information would be more discoverable in the CSRF
reference documentation, either in the "How to use it" section or in a new
section.

We should talk about:
- the API offered by built-in template backends
- requirements for third-party backends, as described in PEP 182
(basically they have to provide a solution, but that solution isn't
specified)

This will likely require tweaking the content a bit to clarify that the
main examples are specific to Django templates.

--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:6>

Django

unread,
May 10, 2016, 9:23:38 PM5/10/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+-------------------------------------
Reporter: aaugustin | Owner: betojulio
Type: Bug | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------

Comment (by betojulio):

ok, I am working on it!

--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:7>

Django

unread,
May 11, 2016, 4:27:07 PM5/11/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+-------------------------------------
Reporter: aaugustin | Owner: betojulio
Type: Bug | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------

Comment (by betojulio):

>{% csrf_token %} in Django templates translates to {{ csrf_input }} in
Jinja2 templates

This is already specified in
https://docs.djangoproject.com/en/dev/ref/csrf/#other-template-engines

>{{ csrf_token }} works identically in Django templates and in Jinja2
templates

Should I put another example in step # 2 in
https://docs.djangoproject.com/en/dev/ref/csrf/#how-to-use-it ?, something
like


{{{
<div style="display:none">
<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token
}}">
</div>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:8>

Django

unread,
May 12, 2016, 2:40:32 AM5/12/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+-------------------------------------
Reporter: aaugustin | Owner: betojulio
Type: Bug | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------

Comment (by aaugustin):

The paragraph you just linked to only mentions `{{ csrf_token }}`, not `{{
csrf_input }}`.

It's precisely because it's incomplete that I filed this ticket.

--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:9>

Django

unread,
Jun 2, 2016, 1:21:51 PM6/2/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+------------------------------------
Reporter: aaugustin | Owner:

Type: Bug | Status: new
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by carljm):

* status: assigned => new
* owner: betojulio =>


Comment:

Since it's been three weeks without a status update, I'm freeing this
ticket up for claiming by a PyCon sprinter.

--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:10>

Django

unread,
Jun 2, 2016, 1:35:05 PM6/2/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+-------------------------------------
Reporter: aaugustin | Owner: bjcubsfan
Type: Bug | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by bjcubsfan):

* owner: => bjcubsfan


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:11>

Django

unread,
Jun 2, 2016, 1:36:47 PM6/2/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+------------------------------------
Reporter: aaugustin | Owner: phildini
Type: Bug | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by phildini):

* owner: bjcubsfan => phildini


--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:12>

Django

unread,
Jun 2, 2016, 1:37:19 PM6/2/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+------------------------------------
Reporter: aaugustin | Owner:

Type: Bug | Status: new
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by phildini):

* owner: phildini =>


* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:13>

Django

unread,
Jun 2, 2016, 1:39:13 PM6/2/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+-------------------------------------
Reporter: aaugustin | Owner: bjcubsfan
Type: Bug | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by bjcubsfan):

* status: new => assigned
* owner: => bjcubsfan


--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:14>

Django

unread,
Jun 2, 2016, 2:46:12 PM6/2/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+-------------------------------------
Reporter: aaugustin | Owner: bjcubsfan
Type: Bug | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by bjcubsfan):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:15>

Django

unread,
Jun 2, 2016, 3:33:39 PM6/2/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+-------------------------------------
Reporter: aaugustin | Owner: bjcubsfan
Type: Bug | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------

Comment (by bjcubsfan):

Replying to [comment:6 aaugustin]:


> I believe this information would be more discoverable in the CSRF
reference documentation, either in the "How to use it" section or in a new
section.
>
> We should talk about:
> - the API offered by built-in template backends
> - requirements for third-party backends, as described in PEP 182
(basically they have to provide a solution, but that solution isn't
specified)
>
> This will likely require tweaking the content a bit to clarify that the
main examples are specific to Django templates.

I think you mean [https://github.com/django/deps/blob/master/final/0182
-multiple-template-engines.rst DEP 182].

--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:16>

Django

unread,
Jun 2, 2016, 7:21:30 PM6/2/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+-------------------------------------
Reporter: aaugustin | Owner: bjcubsfan
Type: Bug | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by carljm):

* needs_better_patch: 0 => 1

Django

unread,
Jun 2, 2016, 7:37:23 PM6/2/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------+-------------------------------------
Reporter: aaugustin | Owner: bjcubsfan
Type: Bug | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by bjcubsfan):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:17>

Django

unread,
Jun 2, 2016, 7:44:36 PM6/2/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------------+-------------------------------------

Reporter: aaugustin | Owner: bjcubsfan
Type: Bug | Status: assigned
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by carljm):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:18>

Django

unread,
Jun 3, 2016, 3:25:19 PM6/3/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: bjcubsfan
Type: Bug | Status: closed
Component: Documentation | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"9c53facc45908bc0593de194a60bc75e5d34a48e" 9c53facc]:
{{{
#!CommitTicketReference repository=""
revision="9c53facc45908bc0593de194a60bc75e5d34a48e"
Fixed #26596 -- Added Jinja2 {{ csrf_input }} documentation.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:19>

Django

unread,
Jun 3, 2016, 3:26:08 PM6/3/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: bjcubsfan
Type: Bug | Status: closed
Component: Documentation | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"926529d6189bd0749067f8567b4e34bbf8b0e545" 926529d]:
{{{
#!CommitTicketReference repository=""
revision="926529d6189bd0749067f8567b4e34bbf8b0e545"
[1.10.x] Fixed #26596 -- Added Jinja2 {{ csrf_input }} documentation.

Backport of 9c53facc45908bc0593de194a60bc75e5d34a48e from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:20>

Django

unread,
Jun 3, 2016, 3:26:09 PM6/3/16
to django-...@googlegroups.com
#26596: Document {{ csrf_input }} in Jinja2 templates
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: bjcubsfan
Type: Bug | Status: closed
Component: Documentation | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"16ce7a51ea5147949d652f8bf60b6e215ec16d8d" 16ce7a51]:
{{{
#!CommitTicketReference repository=""
revision="16ce7a51ea5147949d652f8bf60b6e215ec16d8d"
[1.9.x] Fixed #26596 -- Added Jinja2 {{ csrf_input }} documentation.

Backport of 9c53facc45908bc0593de194a60bc75e5d34a48e from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26596#comment:21>

Reply all
Reply to author
Forward
0 new messages