I have a simple Delete function to drop scheduled events. Here’s the function:
def delete_sch_item(request, scPK):
redirect_to = request.REQUEST.get('next', '')
s = Schedule_Item.objects.get(pk=scPK)
s.delete()
return HttpResponseRedirect(redirect_to)
Every time I call this view by way of a url, it ALWAYS returns the error:
DoesNotExist at /schedule/delete-event/60/
Schedule_Item matching query does not exist.
Even though I look at the raw database and see that, yes, that item does exist. Even more confusing is that when I go back to viewing my list of scheduled items, the one that appearantly “Does Not Exist” has, in fact, been deleted.
What’s going on?!
For some reason your view is being called twice. The first call deletes the object, and the second call throws the exception.