mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 13:00:12 +03:00
Personal fix for issue: #2566
When an HTML form is used to submit data to DRF this function parse_html_list is called. This functions can't parse a list of strings. To work around this, post the data as a valid JSON list: ```["example string 1", "test string 2"]``` This list is parsed as JSON and returned. Thus allowing a formdata with a list to be submitted.
This commit is contained in:
parent
5aa204e94f
commit
f15d2203d7
|
@ -49,6 +49,12 @@ def parse_html_list(dictionary, prefix=''):
|
|||
for field, value in dictionary.items():
|
||||
match = regex.match(field)
|
||||
if not match:
|
||||
try:
|
||||
normalized_value = json.loads(value)
|
||||
except ValueError:
|
||||
continue
|
||||
if field == prefix and isinstance(normalized_value, list):
|
||||
return normalized_value
|
||||
continue
|
||||
index, key = match.groups()
|
||||
index = int(index)
|
||||
|
|
Loading…
Reference in New Issue
Block a user