How do you print out "{{text}}" in a Django template? If I type it into a Django html template it gets interpreted as the variable text. I want the actual text:
{{text}}
To appear in the html output.
How do you print out "{{text}}" in a Django template? If I type it into a Django html template it gets interpreted as the variable text. I want the actual text:
{{text}}
To appear in the html output.
The best way is to use the templatetag tag. However, if i recall correctly, using {{ "{{text}}" }}
will also work, this is however undocumented behaviour, so there is no real guarantee this will never break.
To output the characters used to compose template tags, you have to use a specific template tag called templatetag
. If you want to output the {{
characters, for example, you use {% openvariable %}
and the output of that template tag would be {{
.
So for your example,
{% openvariable %} text {% closevariable %}
would output:
{{ text }}