Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在html表格中显示自动递增序列号_Html_Css_Django - Fatal编程技术网

在html表格中显示自动递增序列号

在html表格中显示自动递增序列号,html,css,django,Html,Css,Django,我有一个django项目。在模板html页面中,我使用一个表来演示数据。在表的第一行,我想显示“I”的ID。但由于i.0是模型的批处理id,因此它不会从1开始递增。如何更改此页面的html以显示从1开始的第一行序列号 <table width="100" border="1" style="table-layout:fixed;position:relative;left:75px;" bordercolor="#E0E0E0"> <tr bgcolor="#F0

我有一个django项目。在模板html页面中,我使用一个表来演示数据。在表的第一行,我想显示“I”的ID。但由于i.0是模型的批处理id,因此它不会从1开始递增。如何更改此页面的html以显示从1开始的第一行序列号

<table width="100" border="1" style="table-layout:fixed;position:relative;left:75px;"  bordercolor="#E0E0E0">
      <tr bgcolor="#F0F0F0">
          <th width="55px" style="word-wrap:break-word;"><div class="panel-heading">ID</div></th>
          <th width="130px" style="word-wrap:break-word;"><div class="panel-heading">Search Content</div></th>
      </tr>
        <tr>
          {% for i in datas %}
           <td style="word-wrap:break-word;"><div class="panel-body"><small>{{ i.0 }}</small></div></td>
           <td style="word-wrap:break-word;color: #0066CC"><div class="panel-body"><strong><small>{{ i.2 }}</small></strong></div></td>
{% endfor %}
        </tr>
    </table>

身份证件
搜索内容
{数据%中的i为%1}
{{i.0}}
{i.2}
{%endfor%}

首先,如果您需要一个包含多行的表,您需要在循环td而不是tr时更改“For loop”的位置。您需要将For loop放在标记上方,endfor应该放在下方。对于与Id相关的疑问,请您向我显示上下文“数据”。

首先,如果您需要一个包含多行的表,您需要更改“For loop”的位置,因为您正在循环td而不是tr。您需要将For loop放在标记上方,endfor应该放在下方。对于与Id相关的疑问,请您向我显示上下文“数据”。

如Parth Modi所述,您当前的循环仅输出td。
如果每组数据都应位于新行中,则需要包装tr

对于您的“序列号”,我想您只需要讨论循环计数,从1开始?
{{forloop.counter}}是您正在搜索的内容


有关这方面的更多信息,请阅读

如Parth Modi所述,当前环路只输出td。
如果每组数据都应位于新行中,则需要包装tr

对于您的“序列号”,我想您只需要讨论循环计数,从1开始?
{{forloop.counter}}是您正在搜索的内容


有关这方面的更多信息,请阅读

是的,我想是的。是的,我想是的。通过使用Nugora建议的模板内置函数可以解决这个问题,thx!通过使用Nugora建议的模板中的内置函数可以解决这个问题,thx!