How can I use a variable as index in django template?
Right now I get this error:
Exception Type: TemplateSyntaxError Exception Value: Could not
It's a very common question, there are a lot of answers on SO.
You can make custom template filter:
@register.filter def return_item(l, i): try: return l[i] except: return None
Usage:
{{ bikesProfit|return_item:year }}