Commit d587ad10 by Tom Christie

Use REST framework request parsing when accessing old-style .POST

parent bb555e6e
...@@ -117,9 +117,8 @@ class SessionAuthentication(BaseAuthentication): ...@@ -117,9 +117,8 @@ class SessionAuthentication(BaseAuthentication):
Otherwise returns `None`. Otherwise returns `None`.
""" """
# Get the underlying HttpRequest object # Get the session-based user from the underlying HttpRequest object
request = request._request user = getattr(request._request, 'user', None)
user = getattr(request, 'user', None)
# Unauthenticated, CSRF validation not required # Unauthenticated, CSRF validation not required
if not user or not user.is_active: if not user or not user.is_active:
......
...@@ -366,6 +366,15 @@ class Request(object): ...@@ -366,6 +366,15 @@ class Request(object):
) )
@property @property
def POST(self):
# Ensure that request.POST uses our request parsing.
if not _hasattr(self, '_data'):
self._load_data_and_files()
if is_form_media_type(self.content_type):
return self.data
return QueryDict('', encoding=self._request._encoding)
@property
def FILES(self): def FILES(self):
# Leave this one alone for backwards compat with Django's request.FILES # Leave this one alone for backwards compat with Django's request.FILES
# Different from the other two cases, which are not valid property # Different from the other two cases, which are not valid property
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment