Py学习  »  问与答

如何原样输出Django模板的变量和标签,不让他渲染

cumt_ttr • 11 年前 • 6702 次点击  

比如,我从Context传过来的是{'var':20}. 我想在页面的输出结果就是 {{ var }} = 20 怎么样写让{{ var }}原样输出,不作渲染?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/543
文章 [ 1 ]  |  最新文章 11 年前
Py站长
Reply   •   1 楼
Py站长    11 年前

I think your answer can be found here:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#templatetag

In short, you want to use {% templatetag openbrace %} and {% templatetag closebrace %}.

Edit: Django now also includes this functionality out of the box:

{% verbatim %} {{ blah blah }} {% endverbatim %}

http://stackoverflow.com/questions/1659492/how-to-put-braces-in-django-templates