躺在沙灘上的小豬

          快樂的每一天

          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

          主站蜘蛛池模板: 宝应县| 泗水县| 忻城县| 镇康县| 盐山县| 石屏县| 余庆县| 乐亭县| 保定市| 罗源县| 万载县| 沐川县| 芷江| 花莲市| 兰州市| 临泽县| 曲靖市| 通山县| 临安市| 双城市| 咸阳市| 商水县| 阳城县| 丰宁| 郓城县| 博湖县| 新余市| 景谷| 浠水县| 武安市| 南安市| 建水县| 太原市| 连州市| 天水市| 泗阳县| 孟州市| 德庆县| 县级市| 盐源县| 越西县|