[Answered ]-Python/Django render enumerated list to table

2👍

There’s no need that loop in the view. The whole thing should be done in the template. Just send the tracks data directly to the template, and use forloop.counter:

{% for data in tracks %}
  <tr>
    <td>{{ forloop.counter }}</td> <td>{{ data }}</td>
  </tr>
{% endfor %}

Leave a comment