功能需求:在前端页面中,for循环id会构不成连续的顺序号,所以要找到一种伪列的方式来根据数据量定义序号

因此就用到了在前端页面中的一个字段 forloop.counter,完美解决

python--django for 循环中,获取序号
 1 <tbody>
 2       {% for inrow in insocket_list %}
 3       <tr>
 4             <!-- 这是序列号(相当于伪列)-->
 5             <td>{{ forloop.counter }}</td>
 6             <td>{{ inrow.inequip }}</td>
 7             <td>{{ inrow.inmodel }}</td>
 8             <td>{{ inrow.innumber }}</td>
 9             <td>{{ inrow.stocknumber }}</td>
10             <td>{{ inrow.inusername }}</td>
11             <td>{{ inrow.inestablishtime }}</td>
12             <td>{{ inrow.remarks }}</td>
13        </tr>
14        {% endfor %}
15  </tbody>
python--django for 循环中,获取序号

相关文章:

  • 2022-12-23
  • 2021-07-31
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2021-09-21
  • 2022-01-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
  • 2022-01-12
相关资源
相似解决方案