我要做的是通过模板在model.py中设置一个参数。
main_index 上有一个文本框,我想单击“提交”将其发布到结果页面。但是结果页收不到POST,即总是打印“Not Post!”
这是视图:
def main_index(request):
c = {}
c.update(csrf(request))
cmodel = InfoController.objects.all()
print "I am at index"
return render_to_response('infoRetriever/index.html', c)
def results(request):
if not request.method == 'POST':
print "Not Post!"
c = {}
c.update(csrf(request))
cmodel = InfoController()
metaUrl = request.POST['urls']
firstList = cmodel.controller(metaUrl)
print "I am at result"
for item in firstList:
print "items: ", item
return render_to_response('infoRetriever/results.html', { 'firstList': firstList})
模板:
<form action="{% url 'infoRetriever:request_page' %}" method="POST">
{% csrf_token %}
<input type="text" name="urls" size="60" />
<input id="submit" type="submit" value="Click" />
</form>
非常感谢。