Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #2185 -- Changed django.views.decorators.http.require_http_meth…

…ods decorator to use HttpResponseNotAllowed instead of HttpResponseForbidden

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3163 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a09682fd6376159f81de9d6dc8c86ebd4e0b6513 1 parent 551a027
Adrian Holovaty authored June 20, 2006

Showing 1 changed file with 6 additions and 6 deletions. Show diff stats Hide diff stats

  1. 12  django/views/decorators/http.py
12  django/views/decorators/http.py
@@ -4,26 +4,26 @@
4 4
 
5 5
 from django.utils.decorators import decorator_from_middleware
6 6
 from django.middleware.http import ConditionalGetMiddleware
7  
-from django.http import HttpResponseForbidden
  7
+from django.http import HttpResponseNotAllowed
8 8
 
9 9
 conditional_page = decorator_from_middleware(ConditionalGetMiddleware)
10 10
 
11 11
 def require_http_methods(request_method_list):
12 12
     """
13 13
     Decorator to make a view only accept particular request methods.  Usage::
14  
-    
  14
+
15 15
         @require_http_methods(["GET", "POST"])
16 16
         def my_view(request):
17 17
             # I can assume now that only GET or POST requests make it this far
18  
-            # ...    
19  
-            
  18
+            # ...
  19
+
20 20
     Note that request methods ARE case sensitive.
21 21
     """
22 22
     def decorator(func):
23 23
         def inner(request, *args, **kwargs):
24  
-            method = request.META.get("REQUEST_METHOD", None) 
  24
+            method = request.META.get("REQUEST_METHOD", None)
25 25
             if method not in request_method_list:
26  
-                raise HttpResponseForbidden("REQUEST_METHOD '%s' not allowed" % method)
  26
+                return HttpResponseNotAllowed(request_method_list)
27 27
             return func(request, *args, **kwargs)
28 28
         return inner
29 29
     return decorator

0 notes on commit a09682f

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