I have this form where I create submit buttons which each correspond to a Product object:
<form action="/costcorrect/product_choice" method="post">
{% csrf_token %}
{% for product in product_list %}
<div class="product">
<img src="{{product.image_url}}" alt="{{product.name}}">
<h2>{{product.name}}</h2>
<input type="submit" name="{{product.id}}" value="Choose Product">
</div>
{% endfor %}
</form>
I want to get the name of the button the user clicks on, so I know which product was selected.
Other questions (like this one) that are related to this had buttons with fixed names, so it was easy to refer to them. My issue is that I'm not sure what the names of the buttons will be, so I can't refer to them directly in views.