0

I have found this snippet in the django codebase:

# Add support for browsers which only accept GET and POST for now.
def post(self, request, *args, **kwargs):
    return self.delete(request, *args, **kwargs)

What does this mean? Do browsers delete resources with GET / POST requests? Why? Can somebody provide a rationale / history / link for why this might be so?

blueFast
  • 41,341
  • 63
  • 198
  • 344

1 Answers1

0

It's for django.views.generic.edit.DeleteView. Your code is from DeletionMixin, and DeleteView inherit this mixin for delete object.

here's self.delete() code

def delete(self, request, *args, **kwargs):
    """
    Call the delete() method on the fetched object and then redirect to the
    success URL.
    """
    self.object = self.get_object()
    success_url = self.get_success_url()
    self.object.delete()
    return HttpResponseRedirect(success_url)

You can check about DeleteView in docs (here).

Basically, DeleteView receive both get and post for deleting object. That's why

seuling
  • 2,850
  • 1
  • 13
  • 22
  • Sure, but why? Why would I want to delete an object with a POST or GET request? We have an specific DELETE method – blueFast Jun 27 '18 at 08:19