DeleteView using POST method by default

I have set up a very straightforward DeleteView following the documentation example. The only difference is I am overriding get_success_url instead of setting the success_url attribute.

One thing I noticed is that the default behavior is for the /delete route to send a POST request, but I imagined it should be DELETE instead. Is this expected behavior or am I doing something wrong? If it is expected, what did I get wrong? It seems the UpdateView also uses POST instead of PUT.

According to the HTML specification, a web browser will only issue GET, POST, and HEAD verbs.

Therefore, the standard default for all views is to base their processing on those verbs. You are free to implement handlers for other verbs when using AJAX or non-browser requests.

1 Like