在 Django 的 TextField 中禁用 HTML 转义 [英] Disable HTML escaping in Django's TextField

查看:40
本文介绍了在 Django 的 TextField 中禁用 HTML 转义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我写入模型的 TextField 时,如何关闭 Django 的自动 HTML 转义?

How can I turn off Django's automatic HTML escaping, when I write into model's TextField?

推荐答案

就用 django 的 安全 过滤器.在您的模板中,您将执行以下操作:

Just use django's safe filter. In your template you would do something like this:

{{ instance.my_text_field|safe }}

这篇关于在 Django 的 TextField 中禁用 HTML 转义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆