I have in Django a view with an autocomplete search. In the logic of the script, I search for city name or I search by zip code. In the select form it works. Is it possible to display both at the same time?
here my form with the jquery :
<form method="GET" action="{% url 'ville_select' name='name' %}" >
{% csrf_token %}
<label for="villeselect">Ville</label>
<input type="text" name="name" id="villeselect" >
<button type="submit">Go</button>
</form>
$(function () {
$("#villeselect").autocomplete({
source: "{% url 'recherche' %}",
minLength: 3
});
});
</script>
the class for display result in views.py
class VilleSelect(ListView):
model = VilleCountry
template_name = 'ville/ville_select.html'
def get_context_data(self,*arg,**kwargs):
context = super(VilleSelect,self).get_context_data(*arg,**kwargs)
query = self.request.GET.get('name')
context['posts'] = VilleCountry.objects.filter(Q(name__startswith=query) | Q(zip_code__startswith=query) )
return context
currently i have this
and what i want
it is possible to make this.
thank

