Skip to content

Commit d587ad1

Browse files
committed
Use REST framework request parsing when accessing old-style .POST
1 parent bb555e6 commit d587ad1

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

rest_framework/authentication.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ def authenticate(self, request):
117117
Otherwise returns `None`.
118118
"""
119119

120-
# Get the underlying HttpRequest object
121-
request = request._request
122-
user = getattr(request, 'user', None)
120+
# Get the session-based user from the underlying HttpRequest object
121+
user = getattr(request._request, 'user', None)
123122

124123
# Unauthenticated, CSRF validation not required
125124
if not user or not user.is_active:

rest_framework/request.py

+9
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,15 @@ def DATA(self):
365365
'since version 3.0, and has been fully removed as of version 3.2.'
366366
)
367367

368+
@property
369+
def POST(self):
370+
# Ensure that request.POST uses our request parsing.
371+
if not _hasattr(self, '_data'):
372+
self._load_data_and_files()
373+
if is_form_media_type(self.content_type):
374+
return self.data
375+
return QueryDict('', encoding=self._request._encoding)
376+
368377
@property
369378
def FILES(self):
370379
# Leave this one alone for backwards compat with Django's request.FILES

0 commit comments

Comments
 (0)