我有类人
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)
我有删除视图
def delete(request):
query = People.objects.get(pk=id)
query.delete()
return HttpResponse("Deleted!")
我有 html 模板代码
{% 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 %}
如何从模板中获取 person.id 并将其放入删除视图中并删除与我想要的 person.id 对应的对象。