H C H C - 1 year ago 73
JSON Question

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

I currently have a date that is formatted in unicode:

k = u'2015-02-01'

I tried to add this to a list and change it into a string:

date = []

Then I want to pass this as a Django context to my template.

However, the date is showing up with the following:


How do I just rid of $#39; and replace it with a double quote (")?

Thanks much.

Answer Source

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

{{ variable|safe }}

In-view way:

inescapable = Context({'data': data}, autoescape=False)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download