从Django中的POST请求中读取多维数组 [英] Reading multidimensional arrays from a POST request in Django
本文介绍了从Django中的POST请求中读取多维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友[0] [id] 12345678
个朋友[0] [姓名] A
朋友[1] [id] 78901234
朋友[1] [姓名]
这是一个数组的两个项目,名称和id。
有没有自动的方式来接收这个输入作为列表或字典?我似乎无法使.getlist工作
解决方案
这与这个问题。如上所述,我为Django / Python制作了专门的库来处理通过请求发送的多维数组。您可以在GitHub 这里找到它。
I have a jquery client that is sending a POST request with a multidimensional array, something like this:
friends[0][id] 12345678 friends[0][name] Mr A friends[1][id] 78901234 friends[1][name] Mr B
That is, an array of two items, name and id.
Is there an automatic way to receive this input as list or a dictionary? I can't seem to be able to make .getlist work
解决方案
This is related with that question. As stated there, I made special library for Django/Python to handle multidimensional arrays sent through requests. You can find it on GitHub here.
这篇关于从Django中的POST请求中读取多维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文