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>
{%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)
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!
相关推荐
java读取接口代码,形如:http://127.0.0.1:8088/hlapp/train/validationCardInfo?a=X&b=X 这样的接口可以用该方法。
HttpRequest.java程序源码下载
1、windows下使用socket访问http rest服务,包括get和post两种方法,不依赖任何其他库 2、循环接收数据返回数据,解决中文乱码问题 3、基于vs2010的解决方案,可直接运行 4、核心类:CHttpRequest
参看文档:http://blog.csdn.net/sinat_29398599/article/details/52880036
httprequest.c
里面有三种实现方法是我下载别人的整合起来的 如果有需要就下载下来看一下 我的成功了
httpRequest.class.php 在PHP中轻松执行常规HTTP请求。 要求 php5 php5-curl 用法 初始化 $ req = new httpRequest( 'http://example.org/itemPage.html' ); 发出POST请求 $ req -> setPOST ( $ rawPostData );...
HttpRequest 程序 idea2017测试通过,通过HTTP Request获取数据。
用来模拟http请求,包括get和post两种,可以在框中输入body消息,且能打印服务器端的消息响应,包括错误码
# include " HTTPRequest.hpp " try { // you can pass http::InternetProtocol::V6 to Request to make an IPv6 request http::Request request{ " http://test.com/test " }; // send a get request const ...
import org.apache.http.HttpRequest; import org.apache.http.HttpRequestInterceptor; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.NameValuePair; ...
用MFC实现的简单的HTTP的POST和GET方法,方便调用
import org.apache.http.HttpRequest; import org.apache.http.HttpRequestInterceptor; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.NameValuePair; import ...
HttpRequest.HttpPost("http://www.baidu.com/","",ret); ofstream OutFile("C:\\11111111111111.txt"); //利用构造函数创建txt文本,并且打开该文本 OutFile << ret.c_str(); //把字符串内容,写入Test.txt...
asihttprequest大体简介及使用
C#异步请求Http接口 代码封装了Get、Post两种异步请求Http接口的方法;内含调用测试示例。
GET POST DELETE PUT Upload 安装 去获取github.com/kirinlabs/HttpRequest 我们如何使用HttpRequest? 使用http.DefaultTransport创建请求对象 req := HttpRequest . NewRequest () req := HttpRequest . New...
一个c++写的http读取类,完整工程
通用工具类,作用是向指定URL发送GET方法的请求,请求参数是 name1=value1&name2=value2 的形式,并且可以获取远程资源的响应结果。