python - django for loop, acquires serial number

Functional requirements: in the front page, the id constitute a continuous loop for the sequence number, so to find a way to define the number of pseudo-column according to the amount of data

Therefore it uses a field in the front page  forloop.counter , perfect solution

Copy the code
 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>
Copy the code

Guess you like

Origin www.cnblogs.com/zmdComeOn/p/11403225.html