【发布时间】:2018-05-20 09:21:13
【问题描述】:
在 Django 模板中我们可以使用with:
{% with total=business.employees.count %}
{{ total }} employee{{ total|pluralize }}
{% endwith %}
我们可以将with 与if 结合使用
我试过了:
{% with a={%if product.url %}product.url{%else%}default{%endif %} %}
但我得到一个错误:
Could not parse the remainder: '{%if' from '{%if'
【问题讨论】: