Django equivalent of PHP's form value array/associative array

前端 未结 3 1101
甜味超标
甜味超标 2020-12-01 00:36

In PHP, I would do this to get name as an array.



         


        
3条回答
  •  臣服心动
    2020-12-01 01:32

    Django does not provide a way to get associative arrays (dictionaries in Python) from the request object. As the first answer pointed out, you can use .getlist() as needed, or write a function that can take a QueryDict and reorganize it to your liking (pulling out key/value pairs if the key matches some key[*] pattern, for example).

提交回复
热议问题