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:
Roland van Laar 2015-03-02 15:43:21 +01:00
parent 5aa204e94f
commit f15d2203d7

View File

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