I am trying to copy the elements of one list to another, and i am using this piece of code to do that:
{% for i in range(2,7) %}
{{ list1.append(list2|lookup:i) }}
{% endfor %}
list1 is an empty list.
I have also defined this custom filter lookup like this:
@register.filter
def lookup(d, key):
return d[key]
But this does not work , I am getting this error:
TemplateSyntaxError at / expected token ',', got ':'.
What am i doing wrong. I am new to django and jinja template.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…