I have one for loop. And inside i want to access to other variable (array) by foorloop.counter0. How? I have tried like this: {{otherVariable.foorloop.counter0}} but nothing.
And like this works: {{otherVariable.0}}
I have one for loop. And inside i want to access to other variable (array) by foorloop.counter0. How? I have tried like this: {{otherVariable.foorloop.counter0}} but nothing.
And like this works: {{otherVariable.0}}
You can use a custom template filter (http://djangosnippets.org/snippets/2740/) like
{{ otherVariable|get_at_index:forloop.counter0 }
or use the built-in 'slice' template tag (https://docs.djangoproject.com/en/dev/ref/templates/builtins/#slice)
{{otherVariable|slice forloop.counter0 }}
Reference - https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#code-layout
Your custom tags and filters will live in a module inside the templatetags directory, say in a file named 'custom_utils/py'
And in your template you would use the following: {% load custom_utils %}