简体   繁体   English

在Django HTML模板中显示特殊字符

[英]Display special character in Django HTML templates

I wonder how to display special character in Django template 我想知道如何在Django模板中显示特殊字符

In models.py i have chessman=models.CharField contain for example '♝' 在models.py中,我有chessman=models.CharField包含例如'♝' , what suits https://en.wiktionary.org/wiki/%E2%99%9D , but in html templates does not replace to symbol. ,适合https://en.wiktionary.org/wiki/%E2%99%9D的内容 ,但在html模板中不会替换为symbol。

It is problem in encoding on website or .py files or database? 网站或.py文件或数据库的编码有问题吗? Or i have to change type? 还是我必须更改类型?

This is probably because of autoescaping. 这可能是由于自动转义。 If you're sure there's nothing dodgy in your variable as well as that character, you can mark it as safe: 如果您确定变量和该字符中没有任何躲闪的字符,则可以将其标记为安全:

{{ myvar|safe }}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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