我要保存 html code
通过django在数据库中。
在 models.py
我有这个领域
description = models.TextField()
但是当我将数据保存在 中时描述字段通过 Django 管理员 .它显示这样的数据
<h1>This is example</h1>
而不是将其转换为 html。 Here's the Out Put
最佳答案
模板引擎转义 html 默认。显示时必须使用安全标签对其进行过滤。
{{ description |safe }}
或使用自动转义标签
{% autoescape off %}{{ description }}{% endautoescape %}
关于html - 如何通过Django将Html代码保存在数据库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53474988/