title: how to edit data in django?
body: <p>I have retrieved data from the database and displayed it in a table. Now click of EDIT button I want to edit the form.i have sucessfully insert and retrived data from the database but i cant understand how to edit and save into database.</p>
  
  <p>viwes.py</p>
  
  <pre><code> def pramod(request):
       p1 = request.POST.get('name',' ')
       p2 = request.POST.get('address',' ')
       p3 = request.POST.get('city',' ')
       p4 = request.POST.get('sp',' ')
       p5 = request.POST.get('country',' ')
       p6 = request.POST.getlist('chk1[]',' ')
       p7 = request.POST.get('sex',' ')
       books =  Publisher(name=p1,address=p2,city=p3,state_province=p4,country=p5,course=p6,Gender=p7)
       books.save()
       dataset=Publisher.objects.all()
       data={
      'dataset':dataset,
       }
  
       return render(request,'Publisher.html',data)
  </code></pre>
  
  <p>models.py</p>
  
  <pre><code>  class Publisher(models.Model):
          name = models.CharField(max_length=30)
          address = models.CharField(max_length=50)
          city = models.CharField(max_length=60)
          state_province = models.CharField(max_length=30)
          country = models.CharField(max_length=50)
          course = models.CharField(max_length=50)
          Gender = models.CharField(max_length=50)
  </code></pre>
  
  <p>Publisher.html</p>
  
  <pre><code>  &lt;div class="col-lg-4"  style="margin-top: 100px"&gt;
      &lt;form action="/pramod/" method="POST"&gt;
      {% csrf_token %}
  
                   &lt;div class="form-group"&gt;
                      &lt;label&gt;Name&lt;/label&gt;
                          &lt;input type="text" name="name" class="form-control"  /&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-group"&gt;
                      &lt;label&gt;Address&lt;/label&gt;
                          &lt;input type="text" name="address" class="form-control"  /&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                      &lt;label&gt;city&lt;/label&gt;
                          &lt;input type="text" name="city" class="form-control" /&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                      &lt;label&gt;state_province&lt;/label&gt;
                          &lt;input type="text" name="sp" class="form-control" /&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                      &lt;label&gt;country&lt;/label&gt;
                          &lt;input type="text" name="country" class="form-control" /&gt;
                      &lt;/div&gt;
                     &lt;div class="form-group"&gt;
                      &lt;label&gt;Course&lt;/label&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
                     &lt;input type="checkbox" name="chk1[]"  value="Dot.NET"  &gt; Dot.NET
                      &lt;input type="checkbox" name="chk1[]"  value="Python"  &gt; Python
                       &lt;input type="checkbox" name="chk1[]"  value="Django"  &gt; Django
                       &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                      &lt;label&gt;Sex&lt;/label&gt;&amp;nbsp;&amp;nbsp;
                     &lt;input type="radio" name="sex" checked="checked" value="Male" &gt;Male
                     &lt;input type="radio" name="sex" checked="checked" value="Female" &gt;Female
                      &lt;/div&gt;
  
      &lt;button type="submit" class="btn bg-olive btn-block"&gt;save&lt;/button&gt;
      &lt;/form&gt;
    &lt;/div&gt;
      &lt;div class="col-lg-8" style="margin-top: 100px"&gt;
     &lt;table class="table table-striped table-condensed table-bordered "&gt;
  
      &lt;B class="btn-success"&gt;Data&lt;/B&gt; &lt;thead class="btn-primary"&gt;
  
              &lt;tr&gt;
                 &lt;th&gt;Name&lt;/th&gt;
                  &lt;th&gt;Address&lt;/th&gt;
                  &lt;th&gt;city&lt;/th&gt;
                  &lt;th&gt;country&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
           {% for p1 in dataset %}
  
              &lt;tr&gt;
                  &lt;td&gt;{{ p1.name }}&lt;/td&gt;
                  &lt;td &gt;{{ p1.address }}&lt;/td&gt;
                  &lt;td &gt;{{ p1.city }}&lt;/td&gt;
                  &lt;td &gt;{{ p1.country }}&lt;/td&gt;
                  &lt;td&gt;&lt;a href="/pramod1/ pk=p1.id %}"&gt;edit&lt;/a&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;a&gt;Delete&lt;/a&gt;&lt;/td&gt;
              &lt;/tr&gt;
            {% endfor %}
          &lt;/tbody&gt;
  
  &lt;/table&gt;
  </code></pre>
  
  <p></p>