Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 authored June 19, 2006
6  django/http/__init__.py
@@ -265,6 +265,12 @@ def __init__(self, *args, **kwargs):
265 265
         HttpResponse.__init__(self, *args, **kwargs)
266 266
         self.status_code = 403
267 267
 
  268
+class HttpResponseNotAllowed(HttpResponse):
  269
+    def __init__(self, permitted_methods):
  270
+        HttpResponse.__init__(self)
  271
+        self['Allow'] = ', '.join(permitted_methods)
  272
+        self.status_code = 405
  273
+
268 274
 class HttpResponseGone(HttpResponse):
269 275
     def __init__(self, *args, **kwargs):
270 276
         HttpResponse.__init__(self, *args, **kwargs)
4  docs/request_response.txt
@@ -400,6 +400,10 @@ types of HTTP responses. Like ``HttpResponse``, these subclasses live in
400 400
 ``HttpResponseForbidden``
401 401
     Acts just like ``HttpResponse`` but uses a 403 status code.
402 402
 
  403
+``HttpResponseNotAllowed``
  404
+    Like ``HttpResponse``, but uses a 405 status code. Takes a single,
  405
+    required argument: a list of permitted methods (e.g. ``['GET', 'POST']``).
  406
+
403 407
 ``HttpResponseGone``
404 408
     Acts just like ``HttpResponse`` but uses a 410 status code.
405 409
 

0 notes on commit 214d88c

Please sign in to comment.
Something went wrong with that request. Please try again.