【问题标题】:convert string to html code in django template [duplicate]在django模板中将字符串转换为html代码[重复]
【发布时间】:2011-12-08 20:18:42
【问题描述】:

可能重复:
django: rendering a template variable as html

我正在开发一个 django 站点,并且我有一个字符串变量,其中包含 html 标记。我需要将该字符串作为模板上的 html 代码读取。

例如,如果我有一个字符串变量

description = "<ul><li>abc</li><li>def</li><li>ghi</li></ul>"

当我在模板中调用这个字符串变量时,我希望它显示为

  • abc
  • 定义

目前它按原样显示字符串。

非常感谢您对此提供任何帮助。

【问题讨论】:

    标签: html django string tags django-templates


    【解决方案1】:

    【讨论】:

    • 完美运行。我想添加一个像
    • 这样的类来动态设置一些元素的样式。我的 CSS 类被忽略了,我该怎么办?
    猜你喜欢
    相关资源
    最近更新 更多
    热门标签