Capturing a value using Select with Django

0

Good morning. I created a form and entered the names of my clients in a select. When selecting one of them I would like to do a filter but it is not working, it seems that the value of the selected field is not being sent to the view.

Follow the code:

View

@login_required
def home_filtro(request):
    cliente = request.POST.get('cliente.id')
    atas = Ata.objects.filter(cliente=cliente)
    clientes = Cliente.objects.all()
    return render(request, 'core/index.html',
                  {'atas': atas, 'clientes': clientes)

HTML

<!--Filtros-->
<form action="{% url 'core_home_filtro' %}" method="post">
      {% csrf_token %}
      <div class="form-group">
      <select class="form-control" name="cliente_id">
              {% for cliente in clientes %}
                 <option value= "{{cliente.id}}" > {{cliente}} </option>
              {% endfor %}
      </select>
      </div>
      <button type="submit" class="mt-3 btn btn-primary">Filtrar</button>
</form>

Could you please help me find out what's going on?

Thank you

    
asked by anonymous 07.09.2018 / 15:39

0 answers