In function
|
def parse_html_list(dictionary, prefix='', default=None): |
We have:
ret = {}
regex = re.compile(r'^%s\[([0-9]+)\](.*)$' % re.escape(prefix))
for field, value in dictionary.items():
match = regex.match(field)
if not match:
continue
index, key = match.groups()
index = int(index)
if not key:
ret[index] = value
elif isinstance(ret.get(index), dict):
ret[index][key] = value
else:
ret[index] = MultiValueDict({key: [value]})
# return the items of the ``ret`` dict, sorted by key, or ``default`` if the dict is empty
return [ret[item] for item in sorted(ret)] if ret else default
But if we send form-data request like this (list of objects for expamle):
firstName:[{"language": 1, "text": "Test"}, {"language": 2, "text": "Test2"}]
Function parse_html_list will work incorrect.
We need in this function something like this:
ret = []
for field, value in dictionary.items():
if field == prefix:
try:
ret = json.loads(value)
break
except:
continue
# return the items of the ``ret`` dict, sorted by key, or ``default`` if the dict is empty
return ret if ret else default
In function
django-rest-framework/rest_framework/utils/html.py
Line 15 in 4137ef4
We have:
But if we send form-data request like this (list of objects for expamle):
firstName:[{"language": 1, "text": "Test"}, {"language": 2, "text": "Test2"}]Function parse_html_list will work incorrect.
We need in this function something like this: