This commit is contained in:
ygavenchuk 2015-02-05 09:47:55 +00:00
commit b2590bdd13
2 changed files with 16 additions and 2 deletions

View File

@ -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 (

View File

@ -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