这是我的代码片段。为什么render_to_response无法正常工作
soup=BeautifulSoup(html_document)
tabulka=soup.find("table",width="100%")
dls=tabulka.findAll("dl",{"class":"resultClassify"})
tps=tabulka.findAll("div",{"class":"pageT clearfix"})
return render_to_response('result.html',{'search_key':search_key,'turnpages
':tps,'bookmarks':dls})
我检查了DLS,它是一个字典只包含一个HTML标签
<dl>label contents contains some <dd> labels</dl>
但经过通DLS选择render_to_response到的结果是不正确的。 在result.html相应的模板的代码是:
{% if bookmarks %}
{% for bookmark in bookmarks %}
{{bookmark|safe}}
{% endfor %}
{% else %}
<p>No bookmarks found.</p>
{% endif %}
输出结果的HTML包含这样一个Python字典格式:
[<dd>some html</dd>,<dd>some html</dd>,<dd>some html</dd>,...]
这出现在输出HTML。这很奇怪。这是一个renfer_to_response的bug吗?
+1提到的安全性方面 – heinrich5991