Python 带有nginx和django的Unicodeer错误
我尝试过,在运行nginx时,我添加了Python 带有nginx和django的Unicodeer错误,python,django,nginx,Python,Django,Nginx,我尝试过,在运行nginx时,我添加了字符集utf-8到我的nginx配置,我仍然得到这个错误 总结的回溯如下: UnicodeEncodeError at / 'ascii' codec can't encode character u'\xe1' in position 69: ordinal not in range(128) Request Method: GET Request URL: http://django/ Django Version: 1.4.
字符集utf-8代码>到我的nginx配置,我仍然得到这个错误
总结的回溯如下:
UnicodeEncodeError at /
'ascii' codec can't encode character u'\xe1' in position 69: ordinal not in range(128)
Request Method: GET
Request URL: http://django/
Django Version: 1.4.20
Exception Type: UnicodeEncodeError
Exception Value:
'ascii' codec can't encode character u'\xe1' in position 69: ordinal not in range(128)
Exception Location: /opt/envs/venv/lib/python2.7/genericpath.py in getmtime, line 54
Unicode error hint
The string that could not be encoded/decoded was: choacán.jpg
我认为这个错误与nginx无关。在文件创建步骤中。
Python在保存文件时使用系统区域设置
检查您的系统区域设置:
$ python manage.py shell
> import os
> print os.popen("locale").read()
如果不正确,则应设置系统区域设置
但是像这样的文件名会给用户带来任何麻烦。请考虑为models.FileField定义自定义文件存储,并为每个文件生成随机文件名,这是一个很好的做法。您在settings.py中使用了_I18N=True?是的,我使用。这一直都是我的梦想。这是一个在不同盒子上工作的站点,因此不太可能是django问题,因为在其他地方成功地使用了相同的代码、相同的venv和相同的设置。