Suppose I have a template

<input type="text" name="text" id="{{product.id}}" > 

How can I get the id value of this input in views.py? For example, to write id in args['id_input'] I can get the value field:

 args['id_input']=request.POST.get("text", "") 

And how to get the id field?

  • No, the browser transmits only the values ​​of the name and value attributes. - Sergey Gornostaev

1 answer 1

You can for example in HTML put a hidden field next to this field,

<input type='hidden' name="product_id" value="{{product.id}}"/>

On the Flask side, you can get by the field name - args['id_input']=request.POST.get("product_id", "")

Of course, in this case, the id attribute is better to remove the field named text .