Click here to Skip to main content
14,241,673 members
Rate this:
Please Sign up or sign in to vote.
See more:
how to dispaly data in dropdown when i click on first dropdown item ,means related or filtered data suppose i click on city dropdown all the city related devices from same table will be displayed for perticular city  in python django 

What I have tried:
def show3(request):
employees = Employee.objects.all().values('city').distinct()
if 'nameEmployees' in request.GET:
nameEmployees = 'nameEmployees' in request.POST and request.POST['nameEmployees']
employees = Employee.objects.filter(Q(city__contains='nameEmployees'))
return render(request, 'testapp/show3.html', {'employees':employees })

<form class="form" method="POST" action="show3">
                                <select id="nameEmployees" name="nameEmployees" class="form-control" onchange="get_host_name(this.value)">
                                        <option value="%">---------</option>
                                        {% for employee in employees %}
                                            <option value="{{ }}">{{ }}</option>
                                        {% endfor %}<br>



{% for employee in employees %}

{{ employee.host_name }}

{% endfor %}
Updated 12-May-19 23:48pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100