繁体   English   中英

处理Django发布请求-一个值被分配而其他分配失败不知道为什么

[英]Processing a django post request - one value getting assigned and other failes to assign dont know why

尝试从html的简单帖子。

当我在django中收到请求时,我只是打印后请求。 (计数未反映在我的输出dunno y ..中)

        print "counterUpdate"
    print request.method
    print request.path
    print request.POST.get
    print "Expects data of counts in next line console print but it is empty"
    countValues=request.POST['counts'] # counts is not getting reflected in my output dunno y..
    updateType=request.POST['key']
    print countValues
    print updateType
    print "dddd1"
    for data in request.POST:
        print data
    print "Iteration Over"

列出以下内容:

counterUpdate
POST
/testapp/counterUpdate
<bound method QueryDict.get of <QueryDict: {u'counts': [u'100', u'100', u'', u''], u'key': [u'increase']}>>
Expects data of counts in next line console print but it is empty

increase
dddd1
counts
key
Iteration Over

您必须像这样使用getlist:

request.POST.getlist('counts')

有关更多信息: Django:使用<select multiple>和POST

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM