0

See this answer. In short, it transforms:

<input type="text" name="object[0][color]" value="red">
<input type="text" name="object[0][doors]" value="2">
<input type="text" name="object[0][color]" value="green">
<input type="text" name="object[0][doors]" value="4>

Into a PHP associative array:

'object' => array(
    '0'=>array(
        'color'=>'red',
        'doors'=>'2'
    ),
    '1'=>array(
        'color'=>'green',
        'doors'=>'4'
    )
)

In Django, I try to do the same, but when I print request.POST, I get:

<QueryDict: {'object[0][color]': ['red'], 'object[0][doors]': ['2'], 'object[1][color]': ['green'], 'object[1][doors]': ['4']}>

How to convert it to a proper dict?

Jorjon
  • 5,316
  • 1
  • 41
  • 58

1 Answers1

-1

This should work:

myDict = dict(queryDict.iterlists())

badiya
  • 2,247
  • 13
  • 23