Click here to Skip to main content
15,443,018 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 :

HTML
<a href="{% url 'deleteuser' id=vr.id %}" class="btn btn-danger"> Delete</a>


urls.py :

Python
path('deleteuser/<int:id>', views.deleteuser, name='deleteuser'),


views.py :

Python
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
Python
<pre>return redirect("alluser", context)

Python
<pre>return render(request,"alluser.html", context)

Python
<pre>return HttpResponseRedirect("alluser", context)
Posted
Comments
Mathis 2022 9-Jul-22 7:51am    
What exact error is shown and where?
Member 15696853 11-Jul-22 3:32am    
https://drive.google.com/file/d/1yUjfq0kX1jrVJ4zszLLhmlvGFraLguBN/view?usp=sharing

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900