【发布时间】:2011-11-28 20:40:16
【问题描述】:
我将如何在 django 中执行以下操作:
{% if value|truncatewords > 10 %} print this {% endif %}
谢谢。
【问题讨论】:
-
你想做什么?为什么要将字符串与整数进行比较?
我将如何在 django 中执行以下操作:
{% if value|truncatewords > 10 %} print this {% endif %}
谢谢。
【问题讨论】:
我打赌你想计算字符串中的单词。试试这个:
{% if value|wordcount > 10 %} print this {% endif %}
【讨论】:
这是对truncatewords 过滤器的错误使用。您必须指定要截断的字数:
{{ value|truncatewords:10 }}
【讨论】: