Well, maybe this is a silly question, but i couldn't find the answer so far. So, i am rendering a view in Django (i will do the code generic to make the problem easier), and the python side looks something like this:
...
marray = [1, 2, 3, 4, 5]
...
return render(request, "template.html", {"marray": marray})
Now, in the template.html file, I want to access the array, but the index must be determined by a JavaScript variable:
var index = 2;
var mvar = {{ marray.index }};
console.log(mvar);
Output wanted:
3
Obviously, the previous code does not work, it's just to show what I want. Any suggestions?
Thanks.