mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
Use REST framework request parsing when accessing old-style .POST
This commit is contained in:
parent
bb555e6e5e
commit
d587ad1021
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user