Case I am in /notes/get/1/ where id=1 and I have created a \"Delete Note\" link in note.html. I need it to delete the current note from database and app and redirect
I think below code will solve the problem
Urls.py
url(r'^delete/(?P\d+)/$','project.app.views.delete'),
Views.py
from django.shortcuts import get_object_or_404
from django.http import HttpResponseRedirect
def delete(request, id):
note = get_object_or_404(Note, pk=id).delete()
return HttpResponseRedirect('/notes/all')