I've seen this Q&A:
Django DeleteView without confirmation template
and this one:
but that doesn't address the built-in intended functionality of the DeleteViewm CBV when issued a GET. From the docs (emphasis mine):
"If this view is fetched via GET, it will display a confirmation page that should contain a form that POSTs to the same URL."
The problem is that as I understand it, the rendered template in response to a GET will not included the RequestContext
necessary to include the {% csrf_token %}
in the mentioned POST form. I worked around it for the time being by overriding the get()
method so that it uses render()
to return the page, since it automatically includes the appropriate context.
How do I maximally leverage the DeleteView
? What am I doing wrong that I need to implement the following code in my view?
def get(self, request, *args, **kwargs):
self.object = self.get_object()
context = self.get_context_data(object=self.object)
return render(self.request,'mainapp/template_confirm_delete.html')