[Django]-How to change to string and remove ' from Django tempalates / context?

12👍

You can try to prevent string escape in template like this:

{{ variable|safe }}

In-view way:

from django.utils.safestring import mark_safe
from django.template import Context
data=mark_safe(data) 
inescapable = Context({'data': data}, autoescape=False)

0👍

I know this is old but other people might stumble upon this with the same problem

Try

{% autoscape off %} {{ date }} {% endautoscape %}

It worked fine for me

0👍

When requesting graphs from google charts the data must be sent as a text array. The csv file has to be pure text with no apostrophes.
however
code fragment
data = repr(textData)
returns data bounded by ‘ ‘
this is interpreted as "&#39" in html

The solution to this is to javascript split method
var par = textData.split(""&#39") textArray = par[1] // the part without '
rest of code

👤pmr

Leave a comment