Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #1646 -- Added HttpResponseNotAllowed, as suggested by Ian Hols…

…man.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3144 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 214d88ce86e6257437bf2702ea6ef60e0ae23fad 1 parent a93b1f7
Malcolm Tredinnick malcolmt authored
Showing with 10 additions and 0 deletions.
  1. +6 −0 django/http/__init__.py
  2. +4 −0 docs/request_response.txt
6 django/http/__init__.py
View
@@ -265,6 +265,12 @@ def __init__(self, *args, **kwargs):
HttpResponse.__init__(self, *args, **kwargs)
self.status_code = 403
+class HttpResponseNotAllowed(HttpResponse):
+ def __init__(self, permitted_methods):
+ HttpResponse.__init__(self)
+ self['Allow'] = ', '.join(permitted_methods)
+ self.status_code = 405
+
class HttpResponseGone(HttpResponse):
def __init__(self, *args, **kwargs):
HttpResponse.__init__(self, *args, **kwargs)
4 docs/request_response.txt
View
@@ -400,6 +400,10 @@ types of HTTP responses. Like ``HttpResponse``, these subclasses live in
``HttpResponseForbidden``
Acts just like ``HttpResponse`` but uses a 403 status code.
+``HttpResponseNotAllowed``
+ Like ``HttpResponse``, but uses a 405 status code. Takes a single,
+ required argument: a list of permitted methods (e.g. ``['GET', 'POST']``).
+
``HttpResponseGone``
Acts just like ``HttpResponse`` but uses a 410 status code.
Please sign in to comment.
Something went wrong with that request. Please try again.