I have some django code that prints a BooleanField
it is rendered as True or False, can I change the label to be Agree/Disagree or do I need to write logic for that in the template?
POST form (your current approach) This answer is perfect and I learned a great deal!
What does {{ name }} this mean in Django Templates? {{ name }} will be the output. It will be displayed as name in HTML. The name will be replaced with values of Python variable.
Jinja is similar to the Django template engine but provides Python-like expressions while ensuring that the templates are evaluated in a sandbox. It is a text-based template language and thus can be used to generate any markup as well as source code. Jinja.
{{ 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With