summaryrefslogtreecommitdiff
path: root/django/views/decorators/http.py
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-06-20 03:17:57 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-06-20 03:17:57 +0000
commita09682fd6376159f81de9d6dc8c86ebd4e0b6513 (patch)
treef6387a5f7375c9266fa49482bf885db79fc6d2fb /django/views/decorators/http.py
parent551a0272e62133606d34952c309290c3e48c8a61 (diff)
Fixed #2185 -- Changed django.views.decorators.http.require_http_methods decorator to use HttpResponseNotAllowed instead of HttpResponseForbidden
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3163 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/views/decorators/http.py')
-rw-r--r--django/views/decorators/http.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/django/views/decorators/http.py b/django/views/decorators/http.py
index a15e82fcc7..a62c13fb4d 100644
--- a/django/views/decorators/http.py
+++ b/django/views/decorators/http.py
@@ -4,26 +4,26 @@ Decorators for views based on HTTP headers.
from django.utils.decorators import decorator_from_middleware
from django.middleware.http import ConditionalGetMiddleware
-from django.http import HttpResponseForbidden
+from django.http import HttpResponseNotAllowed
conditional_page = decorator_from_middleware(ConditionalGetMiddleware)
def require_http_methods(request_method_list):
"""
Decorator to make a view only accept particular request methods. Usage::
-
+
@require_http_methods(["GET", "POST"])
def my_view(request):
# I can assume now that only GET or POST requests make it this far
- # ...
-
+ # ...
+
Note that request methods ARE case sensitive.
"""
def decorator(func):
def inner(request, *args, **kwargs):
- method = request.META.get("REQUEST_METHOD", None)
+ method = request.META.get("REQUEST_METHOD", None)
if method not in request_method_list:
- raise HttpResponseForbidden("REQUEST_METHOD '%s' not allowed" % method)
+ return HttpResponseNotAllowed(request_method_list)
return func(request, *args, **kwargs)
return inner
return decorator