About Escaping Curly Braces in Django Templates

The quickest way to escape opening or closing curly braces in Django template is probably to use this syntax:

1
{{ "{" }}{{ "{" }} username {{ "}" }}{{ "}" }}

When you have many of those cases to escape, use the {% verbatim %} template tag:

1
2
3
{% verbatim doc %}
{{ username }}
{% endverbatim doc %}

Tips and Tricks Programming Django 4.2 Django 3.2 Django 2.2