I would like to extract something like bellow:
{% for item in query_ %}
<td>{{ mydictionary[item.id] }}</td>
{% endfor %}
which of course gives me a syntax error. For this purpose I have defined a template tag
@register.filter('get_value_from_dict')
def get_value_from_dict(dict_data, key):
if key:
return dict_data.get(key)
and then use it as follows:
{% for item in query_ %}
<td>{{ mydictionary | get_value_from_dict : item.id }}</td>
{% endfor %}
however it doesnt work and gives me the following error:
get_value_from_dict requires 2 arguments, 1 provided
I was wondering what I am doing wrong.