Shang Wang
Shang Wang

Reputation: 25539

python/django: How can I convert json string to html format?

I'm not sure if this is possible, but I really appreciate it if there's such a thing.

I have a json object that contains a json string that another program returns which is a html code. However, when I render it to the django template, it's just a big trunk of string. I wonder if there's such tool in python/django that can convert a string into "html format" text. Thanks.

Edit: I use json.loads() to load the output of the other program, and extract the useful information, then return it to template. In template I simply use django template syntax like {{ v.response }} to show it. After that the page looks like this:

enter image description here

Upvotes: 0

Views: 2090

Answers (1)

Rob
Rob

Reputation: 361

Assuming you know the string is safe, you can mark as such so that the template engine will not auto-escape it: try {{ v.response|safe }}.

Upvotes: 1

Related Questions