“”(单引号)已转换为'如何更换或修复它?

时间:2019-09-18 04:31:49

标签: javascript jquery html django

我将字典发送给Django模板,其“”已转换为“如何转换或替换它?”

我尝试使用替换功能,但不起作用。

Dictionary_passed = {"-" : "100", "GERMANY" : "1500"}

In the HTML template I got
{'-':'100','GERMANY&#39:'1500' }

on Dictionary_passed.replace(''', ''), I get:
{&#39l-':100, 'GERMANY':1500}


**__all_users is query set returned by auth_User, userprofile is just another table that extends auth_user**

countries_list = dict(collections.Counter(map(lambda z : z.upper().strip(), 100*list(__all_users.values_list('userprofile__country', flat=True)))))

I have passed countries_list to the Django Template

1 个答案:

答案 0 :(得分:1)

我只需要在将其发送到模板之前将其标记为安全文本即可。

一个人可以在这里mark safe

进行检查

谢谢