如何以 POST 形式发送列表/数组并使用滤锅对其进行解码?我已经尝试了几种方法,但到目前为止没有运气。使用如下形式的表单和滤锅架构将引发错误:[1,2,3] is not iterable
示例_1.html:
<form action="path_to_page" method="post">
<input name="ids" type="text" value="[1,2,3]">
<input type="submit">
</form>
示例_1.py:
class IDList(colander.List):
item = colander.SchemaNode(colander.Integer())
class IDS(colander.MappingSchema):
ids = colander.SchemaNode(IDList())
而这种其他方法根本行不通,因为我们无法创建名为ids[]
.
示例_2.html:
<form action="path_to_page" method="post">
<input name="ids[]" type="text" value="1">
<input name="ids[]" type="text" value="2">
<input name="ids[]" type="text" value="3">
<input type="submit">
</form>
有没有办法做到这一点?