我不能使用 django 模板标签换行符和证明

I can not use django template-tag linebreak and justify

我试图证明我从数据库中获取的一些文本是合理的,但我还需要使用模板标签换行符。

html:

<p class="justify">{{ article.contenu|linebreaks }}</p>

css:

.justify
{
    text-align: justify!important;
}

除非我删除换行标记,否则我的文字将无法自圆其说。

知道如何同时使用 justify 和 linebreak 标签吗?

亲切

在模板中,您应该使用安全的模板标签:

<p class="justify">{{ article.contenu|safe }}</p>

如果需要,您也可以在 linebreaks 之前使用 safe

<p class="justify">{{ article.contenu|safe|linebreaks }}</p>

使用这个 Django 过滤器:

<p class="justify">{{ article.contenu|linebreaksbr }}</p>

希望对你有所帮助,谢谢