[Answered ]-Django: Forbidden (CSRF cookie not set.): for DELETE request

1👍

✅

You can not get the ID of object to be deleted in your view and you are using the default value specified in the view that is zero. So it can not find the object. Change your delete url as follow:

 path(r'department/<int:department_id>',views.departmentApi)

And in your view:

department=Departments.objects.get(DepartmentId=department_id)

Leave a comment