开发者

Calling an attribute or function of a variable obtained through a template filter

开发者 https://www.devze.com 2023-02-24 08:46 出处:网络
This is what I want to write: categories|last.translated_name Where categories is a list of Category objects and translated_name is a function in the Category class.

This is what I want to write:

categories|last.translated_name

Where categories is a list of Category objects and translated_name is a function in the Category class.

This is the error when the above invalid syntax is used:

Could not parse the remainder: '.tra开发者_运维问答nslated_name' from 'categories|last.translated_name'


{% with categories|last as last_category %}
    {{ last_category.translated_name }}
{% endwith %}
0

精彩评论

暂无评论...
验证码 换一张
取 消