Django Strip/Remove HTML tags
在php中我们知道如果想要去掉html的标签的话,使用函数strip_tags
在django中如何去去掉html的标签呢,下面是我在google中搜索到的结果。
To strip/remove HTML tags from an existing string we can use the strip_tags
function.
1 | # import the strip_tags |
This is also available as a template tag:
1 | {{ somevalue|striptags }} |
If you want to remove only specific tags you need to use the removetags
1 | from django.template.defaultfilters import removetags |
Also available in template:
1 | {{ value|removetags:"a span"|safe }} |
在模板里面是使用去掉html标签的方法是不是很简单,嘿嘿。
参考的文章:
http://snipplr.com/view/50835/