mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-06 13:30:12 +03:00
Merge 41a1188144
into 3b00824560
This commit is contained in:
commit
b2590bdd13
|
@ -323,7 +323,8 @@ class Request(object):
|
||||||
if not _hasattr(self, '_data'):
|
if not _hasattr(self, '_data'):
|
||||||
self._data, self._files = self._parse()
|
self._data, self._files = self._parse()
|
||||||
if self._files:
|
if self._files:
|
||||||
self._full_data = MergeDict(self._data, self._files)
|
self._full_data = self._data.copy()
|
||||||
|
self._full_data.update(self._files)
|
||||||
else:
|
else:
|
||||||
self._full_data = self._data
|
self._full_data = self._data
|
||||||
|
|
||||||
|
@ -387,7 +388,8 @@ class Request(object):
|
||||||
# At this point we're committed to parsing the request as form data.
|
# At this point we're committed to parsing the request as form data.
|
||||||
self._data = self._request.POST
|
self._data = self._request.POST
|
||||||
self._files = self._request.FILES
|
self._files = self._request.FILES
|
||||||
self._full_data = MergeDict(self._data, self._files)
|
self._full_data = self._data.copy()
|
||||||
|
self._full_data.update(self._files)
|
||||||
|
|
||||||
# Method overloading - change the method and remove the param from the content.
|
# Method overloading - change the method and remove the param from the content.
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -96,6 +96,18 @@ class TestContentParsing(TestCase):
|
||||||
request.parsers = (FormParser(), MultiPartParser())
|
request.parsers = (FormParser(), MultiPartParser())
|
||||||
self.assertEqual(list(request.DATA.items()), list(data.items()))
|
self.assertEqual(list(request.DATA.items()), list(data.items()))
|
||||||
|
|
||||||
|
def test_request_data_with_form_array_content(self):
|
||||||
|
"""
|
||||||
|
Ensure request.data returns content for POST request with form content
|
||||||
|
which contains array (list) values.
|
||||||
|
"""
|
||||||
|
data = {'qwerty': ['uiop', 'blah', ]}
|
||||||
|
request = Request(factory.post('/', data))
|
||||||
|
request.parsers = (FormParser(), MultiPartParser())
|
||||||
|
# QueryDict().items() return only one item from list. To get all items
|
||||||
|
# have to use getlist() method. e.g. `request.data.getlist('qwerty')`
|
||||||
|
self.assertEqual(request.data, data)
|
||||||
|
|
||||||
def test_request_DATA_with_text_content(self):
|
def test_request_DATA_with_text_content(self):
|
||||||
"""
|
"""
|
||||||
Ensure request.DATA returns content for POST request with
|
Ensure request.DATA returns content for POST request with
|
||||||
|
|
Loading…
Reference in New Issue
Block a user