django 模板按原样显示 html 标签

Ash*_*ish 2 html python django

下面是我的工作区/项目名称/模板/应用名称中的 index.html 文件

<!DOCTYPE html>
<html>

    <head>
        <title>my news</title>
    </head>

    <body>
        <h1>look below for news</h1>
        {%if categories%}
            <ul>
                {%for category in categories%}
                    <li>{{category.name}}</li>

                {%endfor%}
            </ul>

        {%endif%}

        {%if headings%}

            <p>
                {%for heading in headings%}

                    <a href="#">{{heading.title}}</a>
                    <br>
                    {{heading.content}}

                {%endfor%}
            </p>

        {%endif%}
    </body>

</html>
Run Code Online (Sandbox Code Playgroud)

问题是<ul><li>标签的工作,并显示是否应该do.the列表<a>标记也显示超链接,但<p>标签和<br>标签没有被渲染并正在显示为文本,不能认为可能是什么疑难问题。我对 Django 相当陌生。 索引.html

Keb*_*dnK 5

尝试使用{{heading.content|safe}}或关闭自动转义(请参阅文档)。