Cannot seem to delete an object number
I seem to have a problem deleting order numbers in Django. In my views, there is an order number equals to some pk value. There is also a submit button which should delete this number in the template. Unfortunately it is doing nothing (not deleting).
For some reason I thought these changes would delete an object, but it's still not working.
Basically I have this.
order = models.Order.objects.get(pk=1219)
if request.POST.get开发者_JAVA百科('delete'):
order.delete()
And in my template I have this.
<input type="submit" name="delete" value="Delete" >
Got the answer. :) had
order = models.Order.objects.get(pk=1219)
if request.POST.get('delete'):
order.delete()
in the wrong view! Can't believe I was this stupid.
In the second line you are initializing order
with a tuple.
In the fourth line you call delete()
on that object.
I don't know, if that is what you intended. I cannot make any more sense out of what you wrote. Maybe you could give us some more detail.
精彩评论