i have a problem with django's render_to_string and encoding single quotes.
... = render_to_string('dummy.txt', {'request':request, 'text':text,}, context_instance=RequestContext(request)))
why are only these quotes translated to '#39;' and all other special characters not?
Encode Your Apostrophe You can navigate to Web pages using several methods, such as clicking a bookmark or typing a URL into a browser's address bar. If the URL you need to type contains an apostrophe, replace the apostrophe with %27 and press "Enter" to navigate to the URL.
Single quotes need to be escaped by backslash in single-quoted strings, and double quotes in double-quoted strings.
We can use the backslash ( \ ) escape character to prevent JavaScript from interpreting a quote as the end of the string. The syntax of \' will always be a single quote, and the syntax of \" will always be a double quote, without any fear of breaking the string.
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 %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With