簡體   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