[英]Python list has 3 elements but I can only access the last element
I am processing a POST request in a django view and am expecting a list of strings in one of the dictionary elements. 我正在django视图中处理POST请求,并期望其中一个字典元素中的字符串列表。 I'm using Pycharm to debug the code and I can see that in the dictionary, 3 values are returned but when I try to access that dictionary element, I can only access the last item in the list. 我正在使用Pycharm调试代码,可以看到在字典中返回了3个值,但是当我尝试访问该字典元素时,我只能访问列表中的最后一项。
I'm hoping it's a typecast issue of some sort perhaps? 我希望这可能是某种类型转换问题?
The filepond dictionary is a 3rd party java library I'm using so I have no control over how it gets POSTed back to django. filepond字典是我正在使用的第三方Java库,因此我无法控制它如何回发到Django。
Try using: 尝试使用:
my_list = self.request.POST.getlist('filepond')
Read more about it in Django's Official Documentation . 在Django的官方文档中阅读有关它的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.