简体   繁体   中英

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:

在此处输入图片说明

假设您知道该字符串是安全的,则可以这样标记,以使模板引擎不会自动转义它:尝试{{ v.response|safe }}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM