开发者

can't encode single quote (') using django's render_to_string

开发者 https://www.devze.com 2023-01-21 12:04 出处:网络
i have a problem with django\'s render_to_string and encoding single quotes. ... = render_to_string(\'du开发者_如何学编程mmy.txt\', {\'request\':request, \'text\':text,}, context_instance=RequestCont

i have a problem with django's render_to_string and encoding single quotes.

... = render_to_string('du开发者_如何学编程mmy.txt', {'request':request, 'text':text,}, context_instance=RequestContext(request)))

why are only these quotes translated to '#39;' and all other special characters not?


Automatic escaping. Link now changed to https://code.djangoproject.com/wiki/AutoEscaping


To get your string in plain letters, you need to unescape it. surround your variable in autoescape off template tag. Something like this

{% autoescape off %}
{{ body }}
{% endautoescape %}
0

精彩评论

暂无评论...
验证码 换一张
取 消