title: Get Incremented count after forloop depending on condition in template django
body: <p>Edits: Here is my view.py code and my template to render those lists, so how can i get that count depending on the department id on department list</p>
  
  <p><strong>view.py</strong></p>
  
  <pre><code>def settings(request):
  campuses = Campus.objects.all()
  faculties = Faculty.objects.all()
  departments = Department.objects.all()
  programmes = Programme.objects.all()
  # programme_by_department = programmes.select_related('department')
  # department = Department.objects.get(pk=id)
  programme_in_department = Programme.objects.values('department_id')
  
  
  return render(request, 'settings.html', {'my_campus_list': campuses,
                                           'my_faculty_list': faculties,
                                           'my_department_list': departments,
                                           'my_programme_list': programmes,
                                           'programme_by_department': programme_in_department})
  </code></pre>
  
  <p><strong>department_list.html</strong></p>
  
  <pre><code>{% for my_programme in my_programme_list %}
  &lt;tr&gt;
  &lt;td&gt;
  {{ forloop.counter }}
  &lt;/td&gt;
  &lt;td&gt;&lt;small&gt;{{ my_programme.programme_name }}&lt;/small&gt;&lt;/td&gt;
  &lt;td&gt;&lt;small&gt;{{ my_programme.programme_type }}&lt;/small&gt;&lt;/td&gt;
  &lt;td&gt;&lt;small&gt;{{ my_programme.department.department_name }}&lt;/small&gt;&lt;/td&gt;
  
  &lt;td&gt;
  
      &lt;a href="#" onclick="return false;" type="button" class="js-update-programme"  data-url="{% url 'programme_update' my_programme.id %}"&gt;&lt;i class="fa fa-pencil-square-o"&gt;&lt;/i&gt;&lt;/a&gt;
  
      &lt;a href="#" onclick="return false;" type="button" class="js-programme-delete" data-target="#modal-programme" data-url="{% url 'programme_delete' programme_id=my_programme.id %}"&gt;&lt;i class="fa fa-trash"&gt;&lt;/i&gt;&lt;/a&gt;
  
  &lt;/td&gt;
  &lt;/tr&gt;
   {% empty %}
      &lt;tr&gt;
        &lt;td colspan="7" class="text-center bg-warning"&gt;No Programmes&lt;/td&gt;
      &lt;/tr&gt;
  
  
  
  {% endfor %}
  </code></pre>