无法解析剩余部分:来自"item [0]" Django的"[0]" [英] Could not parse the remainder: '[0]' from 'item[0]' Django

查看:62
本文介绍了无法解析剩余部分:来自"item [0]" Django的"[0]"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用从列表中获得的值制作一个表,但是每当我尝试访问一个项目时,我都会不断收到错误消息无法解析剩余的:'[0]'from'[item [0]'"在主列表内的列表中.

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 %}

列表是这样的:

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

我尝试改用{%item [0]%},但出现相同的错误.

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

谢谢

推荐答案

您将编写以下内容以获得项目0:

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 }}

这篇关于无法解析剩余部分:来自"item [0]" Django的"[0]"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆