There is a model field, city, it is filled manually when creating the
object.
There is a field in the search form, city. In views.py it looks like this:
views.py:
if 'city' in request.GET:
city = request.GET['city']
if city:
queryset_list = queryset_list.filter(city__iexact=city)
template.html:
<div class="col-md-4 mb-3">
<label class="sr-only">City</label>
<input type="text" name="city" class="form-control" placeholder="City">
</div>
If you enter the name of the city, objects with that name will be selected. It works correctly, but it’s inconvenient.
I want the city not to be entered, but selected from the list. This list should be automatically collected from the fields city. How can this be implemented? Thank!