How to store Form Data (a Django form) to browser's local storage, using javascript and not Django sessions?
<p>I want to take the data from the user through a form (a Django form) and store it  in the browser's local storage, using javascript and without using Django sessions. </p>

<p>My code looks like:</p>

<p>./forms.py :</p>

<pre><code>class digitize(forms.Form):

    medicinename = forms.CharField(label='Medicinename', max_length=100)
    quantity = forms.CharField(label='Quantity', max_length=100)
</code></pre>

<p>./e_commerce.html :</p>

<pre><code>&lt;form id="digitizer_form" role="form" action="/MediciansDigitizer/Presc/" method="post" enctype="multipart/form-data"&gt;

   {% csrf_token %}

   &lt;h3 class="prod_title"&gt;Add Detail&lt;/h3&gt;

   {{iform.as_table}}{{ dform.as_p }}

   &lt;div class=""&gt;
   &lt;button type="Submit" class="btn btn-default btn-lg"&gt;Digitize&lt;/button&gt;
   &lt;/div&gt;

&lt;/form&gt; 

&lt;script&gt;

        window.onload = function() {

        // Check for LocalStorage support.
        if (localStorage) {

            // Add an event listener for form submissions
            document.getElementById('digitizer_form').addEventListener('submit', function() {

            // Get the value of the MedicineName field :

Now, this is where I need help. Here I want to give in the 'MedicineName' 
field of the form defined above, So that
I can get the MedicineName entered by the user from the form
and store it in the browser storage. 
The logic should look something like this:

            // get the value of the MedicineName so that
               I can store it in a variable like this:

             var Medicine = document.getElementById('MedicineName').value; 

//but because I am using a django form, and linking it 
  in the e_commerce.html template through {%csrf_token%} ,
  {{iform.as_table}} and {{ dform.as_p }} 
  and have not assigned any id ('MedicineName') to any element (as 
  I didn't create any form element manually inside the html template, 
but has made a "form class" in forms.py), I can't follow
  this approach and so I am stuck here because I don't know how to 
  do it the other way round.

            // and then Save the variable in localStorage
              like this :
            localStorage.setItem('Medicine', MedicineName);
            });

          }

        }
&lt;/script&gt;
</code></pre>

<p>So, how to use the MedicineName entered by the user from the Django form inside the javascript in the html template, to store the name in my browser's local storage through javascript?</p>

<p>It would be greatly appreciated if anyone could help me with this. Thanks in advance!</p>