When the environment under the line, normal operation, and then when the online environment, the addition of Chinese characters reported the following bug:
1 Traceback (most recent): 2 " views.py " in <module>3 print kwargs4'ASCII ' codec can't encode character u'\xa0' in position 20:ordinal not in range (+)
The guess is that the online environment has gone through a uwsgi, and then went to search Uwsgi Django Unicodeencodeerror
Get a similar answer:
http://stackoverflow.com/questions/24887929/locale-on-django-and-uwsgi-Unicodeencodeerror
Http://chase-seibert.github.io/blog/2014/01/12/python-unicode-console-output.html
Two solutions were found after reading two articles:
1. Add the following configuration in the Uwsgi file
env = Pythonioencoding=utf-8
2. In the Django settings.py file, add
Import SYS Import = codecs.getwriter ('UTF8'= codecs.getwriter ('UTF8 ') (Sys.stderr)
Both of these scenarios have been tried to solve the bug.
Summary: Your TERMIANL can typically handle UTF8 characters just fine. The issue is actually this Python is just getting confused on what encoding the terminal accepts.
Print to the console in Django without unicodeencodeerrors