From 771e2ef167cd56f1a5009f59e3bd053853065b10 Mon Sep 17 00:00:00 2001 From: Ahmed Ossama <58595131+AhmedOssama22dev@users.noreply.github.com> Date: Wed, 4 Aug 2021 02:18:49 +0200 Subject: [PATCH] comments added --- rest_framework/utils/html.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/rest_framework/utils/html.py b/rest_framework/utils/html.py index ce1659f35..1a3bd88da 100644 --- a/rest_framework/utils/html.py +++ b/rest_framework/utils/html.py @@ -44,13 +44,33 @@ def parse_html_list(dictionary, prefix='', default=None): {'foo': 'abc', 'bar': 'def'}, {'foo': 'hij', 'bar': 'klm'} ] + + [{ + '[0]': 'abc', + '[1]': 'def', + '[2]': 'hij' + }, + { + '[3]': 'lmn', + '[4]': 'opq', + '[5]': 'rst'} + ] + --> + [ + 'abc', + 'def', + 'hij', + 'lmn', + 'opq', + 'rst', + ] :returns a list of objects, or the value specified in ``default`` if the list is empty """ if isinstance(dictionary, (list, tuple)): dictionary = str(dictionary)[1:-1] - dictionary = '{' + dictionary[1:-1].replace('}', '').replace('{', '') + '}' - dictionary = eval(dictionary) + dictionary = '{' + dictionary[1:-1].replace('}', '').replace('{', '') + '}' + dictionary = eval(dictionary) ret = {} regex = re.compile(r'^%s\[([0-9]+)\](.*)$' % re.escape(prefix))