aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/views.py
diff options
context:
space:
mode:
authorSébastien Piquemal2012-01-22 21:28:34 +0200
committerSébastien Piquemal2012-01-22 21:28:34 +0200
commitab0b72a7c1a17c6d85530514caa51ce5bd77b592 (patch)
tree7ae2c1dab7033ccc6cf045d7df28f8027f1eac17 /djangorestframework/views.py
parentd1ce9d3914010ddc9f177ff7d6c1a407efea5a1b (diff)
downloaddjango-rest-framework-ab0b72a7c1a17c6d85530514caa51ce5bd77b592.tar.bz2
.DATA, .FILES, overloaded HTTP method, content type and content available directly on the request - see #128
Diffstat (limited to 'djangorestframework/views.py')
-rw-r--r--djangorestframework/views.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/djangorestframework/views.py b/djangorestframework/views.py
index 9f53868b..37eec89f 100644
--- a/djangorestframework/views.py
+++ b/djangorestframework/views.py
@@ -81,7 +81,7 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
Return an HTTP 405 error if an operation is called which does not have a handler method.
"""
raise ErrorResponse(status.HTTP_405_METHOD_NOT_ALLOWED,
- {'detail': 'Method \'%s\' not allowed on this resource.' % self.method})
+ {'detail': 'Method \'%s\' not allowed on this resource.' % request.method})
def initial(self, request, *args, **kargs):
"""
@@ -128,17 +128,20 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
self.headers = {}
try:
+ # Get a custom request, built form the original request instance
+ self.request = request = self.get_request()
+
self.initial(request, *args, **kwargs)
# Authenticate and check request has the relevant permissions
self._check_permissions()
# Get the appropriate handler method
- if self.method.lower() in self.http_method_names:
- handler = getattr(self, self.method.lower(), self.http_method_not_allowed)
+ if request.method.lower() in self.http_method_names:
+ handler = getattr(self, request.method.lower(), self.http_method_not_allowed)
else:
handler = self.http_method_not_allowed
-
+
response_obj = handler(request, *args, **kwargs)
# Allow return value to be either HttpResponse, Response, or an object, or None
@@ -164,7 +167,7 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
'name': get_name(self),
'description': get_description(self),
'renders': self._rendered_media_types,
- 'parses': self._parsed_media_types,
+ 'parses': request._parsed_media_types,
}
form = self.get_bound_form()
if form is not None: