{% include "example.html" with name="John" hide_last_name=True %}
Basically, I am trying to include “example.html” as a sub-template in my main template. Additional context is provided with the mean of passing the keyword arguments name and hide_last_name. While the django template system has no trouble recognize name, it somehow just can’t recognize hide_last_name. I suspect the use of boolean keyword argument in Include tag is now allowed but then I can’t find anywhere in the official docs mentions that. Please help out. Thanks.
Update: This answer applies to old versions of Django. See this answer below for Django >=1.5
Django template would treat the
Trueas a variable and try to find it in context.You could either use non-empty string to represent the true value or assign the true value to the
Truein context, for example throughTEMPLATE_CONTEXT_PROCESSORS: