私のhtmlで:
<form action="/smartlogis/result_material/{{form.DBR_No.value}}/" method="POST">
{{form.as_ul}}
<input type="submit" value="Submit" /></form>
<form action="/smartlogis/result_material/{{form.DBR_No.value}}/" method="GET">
<input type="submit" value="Delete" />
</form>
views.py:
def Matedit1(request、DBR_No):
f = Movement_In.objects.get(DBR_No=DBR_No)
if request.method == 'POST':
form = Movement_ReceiptForm(request.POST, request.FILES, instance=f)
if form.is_valid():
form.save()
return HttpResponseRedirect('/thanks/')
else:
print "ahj"
if request.method == 'GET':
print "dsfsf"
form = Movement_ReceiptForm(request.POST, request.FILES, instance=f)
if request.POST.get('delete'):
form.delete()
return HttpResponseRedirect('/smartlogis/matdelete.html/')
そして今、私が削除ボタンをクリックしている間、それはelseループに入りますが、フォームは削除されません。そしてそれは直接HttpResponseRedirectに行きます