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

This commit is contained in:
Tom Christie 2015-11-04 14:10:51 +00:00
parent bb555e6e5e
commit d587ad1021
2 changed files with 11 additions and 3 deletions

View File

@ -117,9 +117,8 @@ class SessionAuthentication(BaseAuthentication):
Otherwise returns `None`.
"""
# Get the underlying HttpRequest object
request = request._request
user = getattr(request, 'user', None)
# Get the session-based user from the underlying HttpRequest object
user = getattr(request._request, 'user', None)
# Unauthenticated, CSRF validation not required
if not user or not user.is_active:

View File

@ -365,6 +365,15 @@ class Request(object):
'since version 3.0, and has been fully removed as of version 3.2.'
)
@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):
# Leave this one alone for backwards compat with Django's request.FILES