Python 嵌套循环以显示来自模型django的所有数据

Python 嵌套循环以显示来自模型django的所有数据,python,django,Python,Django,我需要在Django中显示模型中的所有数据 我有两个列表,一个有所有的行,另一个有所有的列,你想做什么 {{student.username }} 我试图使用嵌套循环来获取所有数据,我知道这个“row.{column}}”是错误的,但没有找到解决方案 {% for row in rows %} <tr> {% for column in columns %} <td>{{ row.{{column}} }}</td&g

我需要在Django中显示模型中的所有数据

我有两个列表,一个有所有的行,另一个有所有的列,你想做什么

{{student.username }}
我试图使用嵌套循环来获取所有数据,我知道这个“row.{column}}”是错误的,但没有找到解决方案

 {% for row in rows %}
    <tr>
        {% for column in columns %}
          <td>{{ row.{{column}} }}</td>

       {% endfor %}
   </tr>
  {% endfor %}
{%用于行中的行%}
{columns%%中的列的百分比}
{{行{{列}}}
{%endfor%}
{%endfor%}

有谁能指导我如何使用这种方式吗?

您可以查询
学生
,并使用
值列表
仅获取所需的

Ex:

student = student.objects.values_list('column_1', 'column_2')
然后在模板中

 {% for column in student %}
    <tr>
          <td>{{ column }} }}</td>
   </tr>
 {% endfor %}
{student%]中的列的%
{{column}}}
{%endfor%}