Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not parse the remainder: '[0]' from 'item[0]' Django

I am trying to make a table with values I get from a list but I keep getting the error "Could not parse the remainder: '[0]' from 'item[0]'" whenever I try to access an item in a list inside the main list.

The part of the code that is giving me problems is:

{% for item in lista_completa %}
<tr>
    <td>
        {{ item[0] }}
    </td>
    <td>
        {{ item[1] }}
    </td>
</tr>
{% endfor %}

And the list is something like this:

lista_completa = [[1,'a'],[1,'b'],[3,'c']]

I tried using {% item[0] %} instead but I got the same error.

Thanks

like image 638
user2449798 Avatar asked Nov 10 '13 22:11

user2449798


1 Answers

You would write the following to get item 0:

 {{ item.0 }}

Similarly, to get the first item of the first item you'd write:

{{ item.0.0 }}
like image 85
Simeon Visser Avatar answered Nov 18 '22 02:11

Simeon Visser