2011-10-01 32 views
-2

我會怎麼做在Django以下語句:如果使用templatetag

{% if value|truncatewords > 10 %} print this {% endif %} 

謝謝。

+4

你想做什麼?你爲什麼要比較一個字符串與一個整數? – fourk

回答

1

要計算一個字符串的話。試試這個:

{% if value|wordcount > 10 %} print this {% endif %} 
0

這是truncatewords過濾器的錯誤使用。您必須指定您希望以後截斷的單詞數:我打賭

{{ value|truncatewords:10 }}