[Django] #33317: Add note about not overriding parent blocks within conditionals

2 views
Skip to first unread message

Django

unread,
Nov 24, 2021, 7:52:55 AM11/24/21
to django-...@googlegroups.com
#33317: Add note about not overriding parent blocks within conditionals
-------------------------------------+-------------------------------------
Reporter: Nat S | Owner: nobody
Dunn |
Type: | Status: new
Cleanup/optimization |
Component: | Version: 3.2
Documentation | Keywords: block,if,Template
Severity: Normal | inheritance
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When a parent block is overridden in an if condition, the overridden
content is output regardless of the truthiness of the condition. For
example:

{{{
{% if False %}
{% block parent %}Foo{% endblock parent %}
{% endif %}
}}}

Foo gets output, which feels wrong. But according to Mariusz Felisiak's
response at https://code.djangoproject.com/ticket/33311, this is by
design.

It would be great if this could be added to the documentation on
[https://docs.djangoproject.com/en/4.0/ref/templates/language/#template-
inheritance Template Inheritance].

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

Django

unread,
Nov 24, 2021, 2:15:56 PM11/24/21
to django-...@googlegroups.com
#33317: Add note about not overriding parent blocks within conditionals
-------------------------------------+-------------------------------------
Reporter: Nat S Dunn | Owner: Vishal
Type: | Pandey
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2
Severity: Normal | Resolution:
Keywords: block,if,Template | Triage Stage:
inheritance | Unreviewed
Has patch: 0 | Needs documentation: 0

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

* owner: nobody => Vishal Pandey
* status: new => assigned


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

Django

unread,
Nov 25, 2021, 2:04:00 AM11/25/21
to django-...@googlegroups.com
#33317: Add note about not overriding parent blocks within conditionals
-------------------------------------+-------------------------------------
Reporter: Nat S Dunn | Owner: Vishal
Type: | Pandey
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2
Severity: Normal | Resolution:
Keywords: block,if,Template | Triage Stage: Accepted
inheritance |
Has patch: 0 | Needs documentation: 0

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

* stage: Unreviewed => Accepted


Comment:

Agreed, a small note

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

Django

unread,
Jul 21, 2022, 7:46:47 AM7/21/22
to django-...@googlegroups.com
#33317: Add note about not overriding parent blocks within conditionals
-------------------------------------+-------------------------------------
Reporter: Nat S Dunn | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Documentation | Version: 3.2
Severity: Normal | Resolution:
Keywords: block,if,Template | Triage Stage: Accepted
inheritance |
Has patch: 0 | Needs documentation: 0

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

-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* easy: 0 => 1


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

Django

unread,
Jul 21, 2022, 1:26:45 PM7/21/22
to django-...@googlegroups.com
#33317: Add note about not overriding parent blocks within conditionals
-------------------------------------+-------------------------------------
Reporter: Nat S Dunn | Owner:
Type: | movileanuv
Cleanup/optimization | Status: assigned

Component: Documentation | Version: 3.2
Severity: Normal | Resolution:
Keywords: block,if,Template | Triage Stage: Accepted
inheritance |
Has patch: 0 | Needs documentation: 0

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

* owner: nobody => movileanuv


* status: new => assigned


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

Django

unread,
Jul 21, 2022, 1:49:31 PM7/21/22
to django-...@googlegroups.com
#33317: Add note about not overriding parent blocks within conditionals
-------------------------------------+-------------------------------------
Reporter: Nat S Dunn | Owner:
Type: | movileanuv
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2
Severity: Normal | Resolution:
Keywords: block,if,Template | Triage Stage: Accepted
inheritance |
Has patch: 0 | Needs documentation: 0

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

Comment (by movileanuv):

Here is a link to my pull request :
https://github.com/django/django/pull/15865

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

Django

unread,
Jul 21, 2022, 3:26:50 PM7/21/22
to django-...@googlegroups.com
#33317: Add note about not overriding parent blocks within conditionals
-------------------------------------+-------------------------------------
Reporter: Nat S Dunn | Owner: Victor
Type: | Status: assigned
Cleanup/optimization |

Component: Documentation | Version: 3.2
Severity: Normal | Resolution:
Keywords: block,if,Template | Triage Stage: Accepted
inheritance |
Has patch: 1 | Needs documentation: 0

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

* has_patch: 0 => 1


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

Django

unread,
Jul 22, 2022, 4:10:19 AM7/22/22
to django-...@googlegroups.com
#33317: Add note about not overriding parent blocks within conditionals
-------------------------------------+-------------------------------------
Reporter: Nat S Dunn | Owner: Victor
Type: | Status: closed

Cleanup/optimization |
Component: Documentation | Version: 3.2
Severity: Normal | Resolution: fixed

Keywords: block,if,Template | Triage Stage: Accepted
inheritance |
Has patch: 1 | Needs documentation: 0

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

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


Comment:

In [changeset:"2fac0a18081dcc77fc860c801e5d727dc90435b3" 2fac0a18]:
{{{
#!CommitTicketReference repository=""
revision="2fac0a18081dcc77fc860c801e5d727dc90435b3"
Fixed #33317 -- Added note about unconditional evaluation of {% block %}
tags.
}}}

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

Django

unread,
Jul 22, 2022, 4:11:02 AM7/22/22
to django-...@googlegroups.com
#33317: Add note about not overriding parent blocks within conditionals
-------------------------------------+-------------------------------------
Reporter: Nat S Dunn | Owner: Victor
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 3.2
Severity: Normal | Resolution: fixed
Keywords: block,if,Template | Triage Stage: Accepted
inheritance |
Has patch: 1 | Needs documentation: 0

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

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"8a2e65c2e6ed7fb2607ebb70142ebf4488f15d41" 8a2e65c2]:
{{{
#!CommitTicketReference repository=""
revision="8a2e65c2e6ed7fb2607ebb70142ebf4488f15d41"
[4.1.x] Fixed #33317 -- Added note about unconditional evaluation of {%
block %} tags.

Backport of 2fac0a18081dcc77fc860c801e5d727dc90435b3 from main
}}}

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

Reply all
Reply to author
Forward
0 new messages