Pass values from Django Template for-loop to views in Django

I have following products in the database: enter image description here

Html code for the above image:

        {% for crops_ordered_names,crops_ordered_images,crops_ordered_cost,crops_ava in total %}                 <tbody>                     <tr>                         <td data-th="Product">                             <div class="row">                                 <div class="col-sm-2 hidden-xs"><img src="http://placehold.it/100x100" alt="..." class="img-responsive"/></div>                                 <div class="col-sm-10">                                     <h4 class="nomargin">{{crops_ordered_names}}</h4>                                     <p>Available amount: {{crops_ava}}</p>                                 </div>                             </div>                         </td>                         <td data-th="Price" data-type="price">{{crops_ordered_cost}}</td>                         <td data-th="Quantity">                             <input type="number" class="form-control text-center" data-type="quan"  min="1" max="{{crops_ava}}" >                         </td>                         <td data-th="Subtotal" class="text-center" data-type="subtotal"></td>                         <td class="actions" data-th="">                             <a href="{% url 'shopping_cart:delete_item' crops_ordered_names%}">                             <button class="btn btn-danger btn-sm"><i class="fa fa-trash-o"></i></button>                             </a>                         </td>                     </tr>                 </tbody> 

How can I send the value quantity of each item to the django views to store quantity of each item to the respective product when I submit the form after entering all the quantities. I need to get value of quantity from the HTML code:

<input type="number" class="form-control text-center" data-type="quan"  min="1" max="{{crops_ava}}" > 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.