简体   繁体   中英

Alias attribute in a django template

Could we make an alias on an attribute in a django template? I think this is not work, but I tried {% loan.customer as customer %} .

Thanks!

You probably want the with template tag.

{% with loan.customer as customer %}     
    <div>{{customer}}</div>
{% endwith %}

this is old style but still supported see the django documentation for new style and more info.

For now, New style

{% with customer=loan.customer %}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM