after deleting records it is not redirecting to the page I wanted instead it is showing me an error. But after going back and refresh the page the record is deleted successfully.
Here is the code : -
html page :
<a href="{% url 'deleteuser' id=vr.id %}" class="btn btn-danger"> Delete</a>
urls.py :
path('deleteuser/<int:id>', views.deleteuser, name='deleteuser'),
views.py :
def deleteuser(request,id):
candidate = candidate_details.objects.get(id=id).delete()
context = {
'candidate' : candidate
}
messages.success(request, "User Deleted successfully..")
return redirect("alluser", context)
and Here is the link containing the screenshot of error after redirecting.
What I have tried:
I've tried many redirection code like
<pre>return redirect("alluser", context)
<pre>return render(request,"alluser.html", context)
<pre>return HttpResponseRedirect("alluser", context)