Possible bug in interaction between 'block' and 'include' in Django Templates

34 views
Skip to first unread message

Suriya Subramanian

unread,
Sep 10, 2015, 5:25:42 AM9/10/15
to Django users
Hi,

I think there is a bug in how 'block' and 'include' template tags interact in the Django Template Language. I have created a Gist showing this issue: https://gist.github.com/anonymous/2627bb35955db77dbfaa

The order of the files in the Gist can be a bit confusing. I will explain what I am trying to do here. I have a base template that defines two blocks, one block directly, and one block within an included file. A child template extends the base template and defines both the blocks. However, in the rendered output the child is able to override only of the blocks. The child template is unable to override the block defined in the include file.

My understand is that, a file and block included within a parent template should be considered a part of the parent. However, that does not seem to be the case.

Thanks,
Suriya

Suriya Subramanian

unread,
Sep 10, 2015, 5:33:55 AM9/10/15
to Django users
I got the answer on IRC that this is not a bug as explained in the documentation for include https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#include

Suriya
Reply all
Reply to author
Forward
0 new messages