-1

htmlから簡単な投稿をしようとしています..

django でリクエストを受け取ったら、プリント ポスト リクエストを実行します。(カウントが私の出力に反映されていません..)

        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
4

1 に答える 1

3

次のように getlist を使用する必要があります。

request.POST.getlist('counts')

詳細情報: Django: <select multiple> と POST を使用

于 2013-02-26T10:18:20.377 に答える