【问题标题】:List(array) of HTML element with django 2.0.6带有 django 2.0.6 的 HTML 元素的列表(数组)
【发布时间】:2018-12-19 15:05:38
【问题描述】:

我将 HTML 元素列表从 html 通过 post 传递给 views.py,但我只是得到最后一个值。

这是我使用的 html 代码,这一行的多行

<input name="idborrow[]" id="borrow" value='+element[i].id+'>

这是我在views.py中的代码

if request.method == 'POST':
    idborrow = request.POST.get('idborrow[]', '')

    print (idborrow)

在控制台中,它只打印最后一个值,如何获取整个值列表

【问题讨论】:

  • request.POST.getlist('idborrow[]')?

标签: html django python-3.x django-2.0


【解决方案1】:

尝试使用 getlist

例如:

request.POST.getlist('idborrow[]')

【讨论】:

    猜你喜欢
    • 2019-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多