Good evening!
I created a view where I retrieve the sellers and created a variable (sales_id) to receive the selected salesperson on the screen. The html is being created correctly, but the variable in the view does not receive value in POST:
View:
def novo_orcamento(request):
vendedores = Vendedor.objects.order_by('nome')
id_vendedor = 0
if request.method == 'POST':
import pdb
pdb.set_trace()
context = {'vendedores':vendedores, 'id_vendedor':id_vendedor}
return render(request, 'appOrcamento/novo_orcamento.html', context)
Html
{% block content %}
<form action="{% url 'appOrcamento:novo_orcamento' %}" method="POST">
{% csrf_token %}
<div class="form-group">
<legend class="lead">PRODUTOS</legend>
<select name=id_vendedor class="form-control">
{% for vendedor in vendedores %}
<option value="{{vendedor.codigo_id}}">{{vendedor.nome}}</option>
{% endfor %}
</select>
<button name='submit' class="btn btn-primary">Salvar</button>
</div>
</form>
{% endblock content %}
How do I retrieve the selected seller from the view?