I am using Django DeleteView in a template and I've created a url & view. But it shows "Generic detail view EmployeeDeleteView must be called with either an object pk or a slug in the URLconf." I was looking on django docs, and looks like that DeleteViews are coupled with the models. How can I use Django DeleteView here. If any one help me please.
views.py
class EmployeeDeleteView(DeleteView):
model = Employee
success_url = 'create_employee'
def get(self, request, *args, **kwargs):
return self.post(request, *args, **kwargs)
urls.py
path('delete_employee/<int:id>', EmployeeDeleteView.as_view(), name='delete_employee'),
Delete Button
<button class="deletebtn show-form-delete" type="submit">
<i class="fa fa-trash-o"></i> <a
onclick="return confirm('Are you sure do you want to delete {{i.name}}')"
href="{% url 'delete_employee' i.id %}">Delete</a></button>