躺在沙灘上的小豬

          快樂的每一天

          Can't get params from HttpRequest.POST

          I create a template following django's document:

          <h1>{{poll.question}}</h1>
          {%if error_message%}
          <p><strong>{{error_message}}</strong></p>{%endif%}

          <form action="/polls/{{poll.id}}/vote" method="post">
              {%for choice in poll.get_choice_list%}
                  
          <input type="radio" name="choice" id="choice{{forloop.counter}}" value="{{choice.id}}"/>
                  
          <label for="choice{{forloop.counter}}">{{choice.choice}}</label><br/>
              {%endfor%}
              
          <input type="submit" value="Vote">
          </form>

          And try to get params from post in python:

          def vote(request, poll_id):
              p 
          = get_object_or_404(polls, pk=poll_id)
              
          print request.GET
              
          print request.POST    
              
          return HttpResponseRedirect('/polls/%s/results/' % p.id)

          But the result was null:(

          {}
          {}

          While I change the method to get

          <form action="/polls/{{poll.id}}/vote" method="get">

          I can get the params's value.
          {'choice': ['1']}
          {}

          I don't know why,I wanna help!

          posted on 2005-12-29 12:47 martin xus 閱讀(289) 評論(1)  編輯  收藏 所屬分類: python

          主站蜘蛛池模板: 视频| 滦南县| 仁怀市| 平江县| 黑河市| 昌邑市| 牡丹江市| 平原县| 驻马店市| 来凤县| 竹山县| 枣强县| 会泽县| 津市市| 新乡市| 永昌县| 富阳市| 青川县| 静海县| 梅河口市| 观塘区| 安图县| 当涂县| 黔西县| 彭阳县| 屏东市| 宝应县| 竹溪县| 林芝县| 清镇市| 嘉黎县| 博白县| 赤水市| 五华县| 吉首市| 农安县| 牡丹江市| 永年县| 来宾市| 横峰县| 上犹县|