How to escape {{ or }} in django template?

前端 未结 10 1924
慢半拍i
慢半拍i 2020-12-01 04:17

Django treats {{ var }} as some variable in its template. How can I escape {{ var }} or {{ or }} such that django does no

10条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 04:59

    Django 1.5 introduced {% verbatim %} template tag. It stops template from parsing contents of this tag:

    {% verbatim %}
        {{ var }}
    {% endverbatim %}
    

    will be rendered as:

    {{ var }}
    

提交回复
热议问题