title: Editing form data in django
body: <p>I am trying to edit a form data but instead of editing, it adds new data. I actually referred the codes online, but I couldn't figure out where I have got wrong.
  The following is the snippet of where I call the edit button</p>
  <pre><code>&lt;a class=&quot;btn btn-secondary&quot; href=&quot;{% url 'ride:edit-ride' i.id %}&quot;&gt;Edit&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  <p>veiws.py</p>
  <pre><code>def edit_ride(request, pk):
      obj = Ride.objects.get(id=pk)
      form = RideForm(instance=obj)
      if request.method == 'POST':
          form = RideForm(request.POST, instance=obj)
          if form.is_valid():
              form.save()
              return redirect('ride_list.html')
      context = {'form': form}
      return render(request, 'offerride/create_ride.html', context)
  </code></pre>