how to get data from html form to function in view

Here, I am trying to make add to cart button in my e-shop application. I created a form that holds the id of a product, after cliking the "add to cart " button i dont want to redirect any where but on the same page and also i want to send id to my function. I have already created function for add to cart. But i am not getting way how can i get that id of product from that html form to my function in my view. Here is my form.

         <form action="cart" method="POST">
            {% csrf_token %}
            <input hidden type="text" name="product" value="{{}}"> 
            <input type="submit" value="Add to cart">

The form is inside for loop.

If you don’t want a full-page refresh, you’ll have to submit the data to a view via an AJAX call using JavaScript. Your view that you’ll write for that purpose then would accept the JSON data being supplied, do whatever needs to be done on the server, and then return a JsonResponse. The JavaScript can then take the response and update whatever elements on the page need to be updated to reflect this change.

To add to Ken’s answer, one potential way of integrating AJAX into your application is to use htmx. There’s a new django package that should assist in setting it up.

However, if you already have some JavaScript elsewhere in your application it might be better to remain consistent in your application rather than mixing methodologies.