Fixed #14558 -- Modified the way PUT and DELETE HTTP methods are handled so that overridden methods will get used correctly. Thanks to pyrou for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14374 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2010-10-28 02:59:04 +00:00
parent 623592e0ac
commit 4c9741cba2
1 changed files with 8 additions and 4 deletions

View File

@ -143,7 +143,8 @@ class ProcessFormView(View):
# PUT is a valid HTTP verb for creating (with a known URL) or editing an
# object, note that browsers only support POST for now.
put = post
def put(self, *args, **kwargs):
return self.post(*args, **kwargs)
class BaseFormView(FormMixin, ProcessFormView):
@ -174,7 +175,8 @@ class BaseCreateView(ModelFormMixin, ProcessFormView):
# PUT is a valid HTTP verb for creating (with a known URL) or editing an
# object, note that browsers only support POST for now.
put = post
def put(self, *args, **kwargs):
return self.post(*args, **kwargs)
class CreateView(SingleObjectTemplateResponseMixin, BaseCreateView):
"""
@ -200,7 +202,8 @@ class BaseUpdateView(ModelFormMixin, ProcessFormView):
# PUT is a valid HTTP verb for creating (with a known URL) or editing an
# object, note that browsers only support POST for now.
put = post
def put(self, *args, **kwargs):
return self.post(*args, **kwargs)
class UpdateView(SingleObjectTemplateResponseMixin, BaseUpdateView):
@ -223,7 +226,8 @@ class DeletionMixin(object):
return HttpResponseRedirect(self.get_success_url())
# Add support for browsers which only accept GET and POST for now.
post = delete
def post(self, *args, **kwargs):
return self.delete(*args, **kwargs)
def get_success_url(self):
if self.success_url: