Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css Django无效筛选器:';truncatechars_html';_Css_Django - Fatal编程技术网

Css Django无效筛选器:';truncatechars_html';

Css Django无效筛选器:';truncatechars_html';,css,django,Css,Django,我试图显示包含HTML标记的内容,如果字符超过1000,我也想截断它,但如果文章在截断点之前打开而未关闭的标记处被截断,则会影响我的CSS布局 代码: {% if article.content_length > 1000 %} <p> {{article.content|truncatechars_html:1000|safe|linebreaks}} </p> <a href="#">See more...&l

我试图显示包含HTML标记的内容,如果字符超过1000,我也想截断它,但如果文章在截断点之前打开而未关闭的标记处被截断,则会影响我的CSS布局

代码:

{% if article.content_length > 1000 %}
    <p>
        {{article.content|truncatechars_html:1000|safe|linebreaks}}
    </p>
    <a href="#">See more...</a>
{% else %}
    <p>
        {{article.content|safe|linebreaks}}
    </p>
{% endif %}                 
{%if article.content_length>1000%}

{{article.content | truncatechars_html:1000 | safe | linebreaks}}

{%else%} {{article.content | safe | linebreaks}}

{%endif%}
虽然
{article.content | truncatechars:1000 | safe | linebreaks}}
工作正常,但当我将其更改为
{{article.content | truncatechars | html:1000 | safe | linebreaks}
时,我得到以下错误:

模板语法错误位于/mysite/article/mysite/


无效筛选器:“truncatechars\u html”

请确保您使用的是Django 1.7或更高版本。
truncatechars\u html
过滤器在早期版本中不可用