私がやりたいことは、テンプレートを介して model.py にパラメーターを設定することです。
main_index にテキスト ボックスがあり、[送信] をクリックして結果ページに POST したい。ただし、結果ページは 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>
どうもありがとうございました。