Django: Non-ASCII character

后端 未结 7 1763
清歌不尽
清歌不尽 2020-12-23 15:12

My Django View/Template is not able to handle special characters. The simple view below fails because of the ñ. I get below error:

Non-ASCII character

7条回答
  •  温柔的废话
    2020-12-23 15:18

    Insert at the top of views.py

    # -*- coding: utf-8 -*-
    

    And add "u" before your string

    my_str = u"plus de détails"
    

    Solved!

提交回复
热议问题