Django 模板中的别名属性
Alias attribute in a django template
我们可以在 Django 模板中为属性创建别名吗?我认为这行不通,但我尝试了 {% loan.customer as customer %}
.
谢谢!
您可能需要 with 模板标签。
{% with loan.customer as customer %}
<div>{{customer}}</div>
{% endwith %}
这是旧样式但仍然支持查看
django documentation 获取新样式和更多信息。
目前,新款式
{% with customer=loan.customer %}
我们可以在 Django 模板中为属性创建别名吗?我认为这行不通,但我尝试了 {% loan.customer as customer %}
.
谢谢!
您可能需要 with 模板标签。
{% with loan.customer as customer %}
<div>{{customer}}</div>
{% endwith %}
这是旧样式但仍然支持查看 django documentation 获取新样式和更多信息。
目前,新款式
{% with customer=loan.customer %}