I'm receiving this error each time I try to access a list within a Django template. I have checked the answers to similar questions, but the problem is usually a lack of %
or some other character somewhere. As long as I can see, this is not the case:
Here I'm passing a dict containing a a list of item id as keys and list of URLs to images as a value for each id. I know I should integrate this into the item model, but since I'm still at development with SQLite3 I cannot store lists easily. And anyway I am intrigued by this problem. So:
<a href="{% url 'details_view' item_id=item.id %}"><img class="hover-image" src="{{ img_gallery[item.id][0] }}" alt="">
Exception Value:
Could not parse the remainder: '['item.id'][0]' from 'img_gallery['item.id'][0]'
Also, yesterday I tried using bootstrap4 flex-grid to easily achieve 5 columns. Since I'm using pagination to retrieve 20 items, my idea was slicing the list of items (model) for each row, like:
{% for item in items[0:5] %}
And I also received the same error, even when this was the recommended aproach in related answers aboput slicing data passed with a view.
In both cases I cannot find the problem, and I think both are somehow related.
I'm using latest Django 1.11.6 with Python 3.5.2.