0👍
You don’t need to use ifchanged here.
You should index your result
with forloop.counter0
but is not possible with django templating system.
You can write a custom tag to do this or change your view adding your result to the object context.
1👍
You have 2 problem :
-
Show Tot only specific empID not all from string :
Ans : You cannot do this because you can’t use variables for attribute names, dictionary keys or list indizes that make you cannot show only specific index in array from your counter. You may need to put this value to your list DBShots1 before show it on template or create a custom template tags.
-
Reset counter every time it change empID :
Ans : You can use regroup function to sort your list that will make another for loop for each empID
https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#regroup
e.g.
{% regroup DBShots1 by eachSc.laEmpNum as emp_list %}
{% for eachSc in emp_list %}
<tr>
<td> </td><td> </td>
<td bgcolor="#FFFACD" width="1%">EmpNum : {{ eachSc.grouper }}</td>
</tr>
{% for item in eachSc.list %}
<td bgcolor="#FFFACD" width="1%">{{ forloop.counter }} </td>
<td bgcolor="#CCFACD" width="1%">{{ item.sName }} </td>
<td bgcolor="#CCF0F5" width="1%">{{ item.duration }}</td>
<td bgcolor="#CCFACD" width="1%">{{ item.frames }}</td>
<td bgcolor="#CCFACD" width="5%">{{ GetEmpDept }} - {{ item.laEmpNum }}</td>
{% endfor %}
{% endfor %}
- [Answer]-Django tables 2: LinkColumn
- [Answer]-Django redirect still shows Form View on redirect
- [Answer]-Creating nested objects in Django REST Framework
- [Answer]-Can you do this with a database?