简体   繁体   中英

Display special character in Django HTML templates

I wonder how to display special character in Django template

In models.py i have chessman=models.CharField contain for example '♝' , what suits https://en.wiktionary.org/wiki/%E2%99%9D , but in html templates does not replace to symbol.

It is problem in encoding on website or .py files or database? 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 }}

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