【发布时间】:2011-01-31 14:49:55
【问题描述】:
使用表格搜索附近的学校并将其显示为表格。
在views.py中
def method1: printquery = request.POST.copy() zip = printquery['zip'] if not zip: city = printquery['city'] state = printquery['state'] zip = getZip(city,state) results = zipObj.getSchools(zip); render_to_response('some.html',{'results':results,'query':printquery,})
模板内
<form id="print-search" target="_blank" action="" method="post" name="print">
<input type="hidden" value="{%if query%}{{query}}{%endif%} name="query"/>
<input type ="submit" value="Print the Results" name="submitPrint"/>
</form>
<table>
{% block xxx%}displays schools result {%endblock%}
</table>
单击“打印结果”按钮时。我想使用“查询”,
再次进行搜索并在单独的页面中打印[我无法选择存储在会话 ID 中]。
我面临的问题是,{{query}} 是一个字符串的图灵,即u"{'zip': u'76123'"},我不能在它上面做类似query['zip'] 的事情,
有没有办法解决这个问题。欢迎提出想法。
【问题讨论】:
标签: django-templates django-views