views.py file

def show3(request):
    employees = Employee.objects.all().order_by().values('city').distinct()
    search4=''
    if 'search4' in request.GET:
       search4 = request.GET.getlist('search4')
       print(search4)
        employees=Employee.objects.filter(id__in=search4).distinct().order_by()
    return render(request,"testapp/show3.html",{'employees':employees})

show3.html file

{% for employee in employees %}
  <li>
      <a href="/show3"><span name="search4" class="glyphicon glyphicon-pencil">{{ employee.city }}</span></a>
  </li>
{% endfor %}


<table class="table table-striped table-boedered table-sm">

  <thead class="thead-dark">
    <tr>
      <th>HostName</th>
    </tr>

  </thead>
  <tbody>
    {% for employee in employees %}
    <tr>
      <td><a href="/edit/{{ employee.id}}"><span class="glyphicon glyphicon-pencil"></span>{{ employee.host_name }}</span></a></td>
</tr>
{% endfor %}

</table> 

I want to display city dropdown and when I click on particular city all the hostname belongs to that city should come all process must be dynamic....thanks in advance

0 Answers