Django: Non-ASCII character

后端 未结 7 1762
清歌不尽
清歌不尽 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:42

    Do you have this at the beginning of your script:

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

    ...?

    See this: http://www.python.org/dev/peps/pep-0263/

    EDIT: For the second problem, it's about the html encoding. Put this in the head of your html page (you should send the request as an html page, otherwise I don't think you will be able to output that character correctly):

    
    

提交回复
热议问题