title: Python Django Edit HTML rows and update database
body: <p>I have a table and I wish to add an edit button that updates the certain record both visually and in the database.</p>
  
  <p>The HTML I have.</p>
  
  <pre><code>{% for work_entry in work_entries %}
                  {% if work_entry.date == date.date %}
                  &lt;form action="{% url 'work_entries:object_edit' work_entry.id %}" method="post"&gt;
                      {% csrf_token %}
                  &lt;tr&gt;
                      &lt;td&gt;
                              &lt;button onclick="return confirm('Are you sure you want this edit?')"&gt;Edit
                              &lt;/button&gt;
                              &lt;/td&gt;
                      &lt;td&gt; &lt;form action="{% url 'work_entries:object_delete' work_entry.id %}" method="post"&gt;
                              {% csrf_token %}
                              &lt;button onclick="return confirm('Are you sure you want to delete this record?')"&gt;Delete
                              &lt;/button&gt;
                              &lt;/form&gt;
                              &lt;/td&gt;
                      &lt;td&gt;{{ work_entry.id }}&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" value="{{ work_entry.description }}" name="description"&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;input type="number" value="{{ work_entry.num_hours }}" name="hours"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;/form&gt;
                  {% endif %}
              {% endfor %}
  </code></pre>
  
  <p>The views.py</p>
  
  <pre><code>def object_edit(request, object_id):
  
      record = get_object_or_404(WorkEntry, pk=object_id)
  
      if request.method == "POST":
          record.description = request.POST["description"]
          record.num_hours = request.POST["hours"]
          record.save()
          return redirect("/employeePage")
  
      return render(request, "employeePage.html")
  </code></pre>
  
  <p>And urls.py</p>
  
  <pre><code>app_name = "work_entries"
  
  urlpatterns = [
      path("", views.employee_view, name="employeePage"),
      url(r"^delete/(?P&lt;object_id&gt;[0-9]+)/$", views.object_delete, name="object_delete"),
      url(r"^edit/(?P&lt;object_id&gt;[0-9]+)/$", views.object_edit, name="object_edit"),
  ]
  </code></pre>
  
  <p>I used an input tag in the  as I thought that would allow me to change data and save it. However this is giving me <strong>MultiValueDictKeyError at /employeePage/edit/14/
  'description'</strong> error. I am not too experienced with jquery which from research I saw that could work but I don't seem to get it right. Can someone help or even suggestions on how I should approach this would be useful.</p>
  
  <p>Note: there is already a button to delete the record which works, I tried a similar approach for editing, but it doesn't work.</p>