我们可以在django模板中为属性创建别名吗?我认为这不起作用,但我尝试了{% loan.customer as customer %}
。
谢谢!
答案 0 :(得分:2)
您可能想要带模板标记。
{% with loan.customer as customer %}
<div>{{customer}}</div>
{% endwith %}
这是旧样式,但仍然支持请参阅 django documentation了解新款式和更多信息。
目前,新款式
{% with customer=loan.customer %}