2012-09-14 155 views

回答

1

您的瀏覽器解釋&sect價值§,部分字符:§

你需要躲避符號作爲&sect防止這種情況:

teststring = "&sect" 

Django模板可以做到這一點轉義爲你使用escape filter,或者您可以使用cgi.escape() function

teststring = cgi.escape("&sect") 
1

在模板中使用django的escape篩選器。例如:

<b>check out my string: {{ teststring|escape }}</b> 

或轉動autoescape

相關問題