How can I change the way a boolean prints in a django template?

{{ bool_var|yesno:"Agree,Disagree" }}

You can also provide an additional string for the None case. See the docs for yesno for details.


Just another way if you want to have more options like adding HTML elements and classes

{% if var == True %} Yes {% else %} No {% endif %}

You can change Yes and No to any html element; an image or span element


Any of the following may be tried with consistent results:

A.

{% if  form.my_bool.value %} 
    {{ "Yes" }} 
{% else %} 
    {{ "No" }} 
{% endif %} 

B.

{{ form.my_bool.value|yesno }}

C.

{{ form.my_bool.value|yesno:"Yes,No" }}

D.

{% if form.my_bool.value == True %} Yes {% else %} No {% endif %}

Or simply,

{{ form.my_bool.value }}    # Here the output will be True or False, as the case may be.