开发者

show fields containing html tag in django templates like ordinary html tag

I have a model named news,news have a field named description,I use a RichTextArea to get the value of desc开发者_高级运维ription from user,so user can enter html tags into this field,now I show the value of description in my template like this:

<div>
<h1>{{news.Title}}</h1>
{{news.Description}}
</div>

imagine that description field contain this text:

this is a test!

  • item1
  • item2
  • item3

template show the value of description in the same way that is saved,I mean it shows tags in the template output not a formatted HTML! what should I do?


You need the safe filter:

{{news.Description|safe}}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜