Reques.POST.get, всегда возвращает none
Я пытаюсь получить значение поля select шаблона, используя request.POST.get. Но даже с правильным именем значение, которое получает представление, всегда None, может кто-нибудь помочь мне, как это решить?
Вот коды:
view:
def efetuar_pagamento(request, id_pagamento):
if request.POST:
objPagamento = Pagamento.objects.select_related(
"Matricula", "FormaPagamento").get(pk=id_pagamento)
valorPago = request.POST.get("Valor_%s" % id_pagamento, None)
formaPaga = request.POST.get("Forma_%s" % id_pagamento, None)
print(formaPaga, valorPago)
objFormaPG = FormaPagamento.objects.get(pk=formaPaga)
objPagamento.ValorParcial = valorPago.replace(',', '.')
objPagamento.FormaPagamento = objFormaPG
objPagamento.save()
if objPagamento.ValorParcial < objPagamento.Matricula.Plano.Valor and objPagamento.ValorParcial:
objPagamento.Status = "PC"
elif objPagamento.ValorParcial >= objPagamento.Matricula.Plano.Valor:
objPagamento.Status = "PG"
Шаблон:
замечено, что имя шаблона совпадает с тем, что получено в request.post.get, но он не захватывает значение поля, а оно есть только в select в текстовом поле "Valor_{{objPagamento.id}}" и захвачено правильно