pancakes
pancakes

Reputation: 761

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

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: '.translated_name' from 'categories|last.translated_name'

Upvotes: 0

Views: 51

Answers (1)

dting
dting

Reputation: 39287

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

Upvotes: 3

Related Questions