I have the class People
class People (models.Model):
first_name = models.CharField(max_length = 50)
last_name = models.CharField(max_length = 50)
email = models.EmailField(blank = True)
grade = models.CharField(max_length = 2)
def __unicode__(self):
return '%s %s' % (self.first_name, self.last_name)
I have the delete view
def delete(request):
query = People.objects.get(pk=id)
query.delete()
return HttpResponse("Deleted!")
And I have the html template code
{% for person in people_list %}
<TR ALIGN="CENTER">
<td>{{ person.first_name }}</td>
<td>{{ person.last_name }}</td>
<td>{{ person.email }}</td>
<td>{{ person.grade }}</td>
<td><form action="/modify.html">
<input type="submit" value="Modify">
</form></td>
<td><form action="/delete.html">
<input type="submit" value="Delete">
</form></td>
</TR>
{% endfor %}
How can I get the person.id from the template and put it in the delete view and delete the object corresponding with the person.id I want.