The custom filter can be used with the following syntax:
{{ b.count | rangef }}
Note that the filter part is inside the curly braces since this will apply the filter rangef
to the value on the left, b.count
.
Note that filters are not supported within for
loops. Consider changing your model so that it exposes the filtered value directly, e.g.
def b_range(self):
return range(self.b.count)
{% for i in b_range %}
…
{% endfor %}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…