aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/views.py
diff options
context:
space:
mode:
authorTom Christie2012-10-17 22:19:59 +0100
committerTom Christie2012-10-17 22:19:59 +0100
commit4231995fbd80e45991975ab81d9e570a9f4b72d0 (patch)
tree6aedfb8cdad5ec1500a4dddcd9bb49026a836255 /rest_framework/views.py
parent99d48f90030d174ef80498b48f56af6489865f0d (diff)
downloaddjango-rest-framework-4231995fbd80e45991975ab81d9e570a9f4b72d0.tar.bz2
parser_context includes `view`, `request`, `args`, `kwargs`. (Not `meta` and `upload_handlers`)
Consistency with renderer API.
Diffstat (limited to 'rest_framework/views.py')
-rw-r--r--rest_framework/views.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/rest_framework/views.py b/rest_framework/views.py
index 1be2593c..066c0bb9 100644
--- a/rest_framework/views.py
+++ b/rest_framework/views.py
@@ -161,9 +161,12 @@ class APIView(View):
Returns a dict that is passed through to Parser.parse(),
as the `parser_context` keyword argument.
"""
+ # Note: Additionally `request` will also be added to the context
+ # by the Request object.
return {
- 'upload_handlers': http_request.upload_handlers,
- 'meta': http_request.META,
+ 'view': self,
+ 'args': getattr(self, 'args', ()),
+ 'kwargs': getattr(self, 'kwargs', {})
}
def get_renderer_context(self):
@@ -171,13 +174,13 @@ class APIView(View):
Returns a dict that is passed through to Renderer.render(),
as the `renderer_context` keyword argument.
"""
- # Note: Additionally 'response' will also be set on the context,
+ # Note: Additionally 'response' will also be added to the context,
# by the Response object.
return {
'view': self,
- 'request': self.request,
- 'args': self.args,
- 'kwargs': self.kwargs
+ 'args': getattr(self, 'args', ()),
+ 'kwargs': getattr(self, 'kwargs', {}),
+ 'request': getattr(self, 'request', None)
}
# API policy instantiation methods