躺在沙灘上的小豬

          快樂的每一天

          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 閱讀(291) 評論(1)  編輯  收藏 所屬分類: python

          主站蜘蛛池模板: 繁峙县| 安平县| 嘉荫县| 巩义市| 富锦市| 南宫市| 从化市| 抚顺市| 乐山市| 河北区| 博罗县| 南宁市| 宝山区| 新建县| 兴国县| 上饶县| 象州县| 远安县| 盱眙县| 社旗县| 黔西县| 黄石市| 乌拉特中旗| 漳平市| 天津市| 建水县| 泉州市| 咸阳市| 通许县| 梅河口市| 察隅县| 济阳县| 大埔县| 宁晋县| 富裕县| 德化县| 玉山县| 湘阴县| 三穗县| 延长县| 美姑县|