问题描述
当使用非ASCII字符上传文件时,我得到UnicodeEncodeError:
异常类型:在/ admin / studio / newsitem中的UnicodeEncodeError / add /
异常值:'ascii'编解码器不能在位置78编码字符u'\xf8':序号不在范围(128)
请参阅。 p>
我运行Django 1.2与MySQL和nginx和FastCGI。
这是一个根据,但我仍然有问题。欢迎任何有关如何修复的建议。
编辑:这是我的图像字段:
image = models.ImageField(_('image'),upload_to ='uploads / images',max_length = 100)
在调查了一些以后,我发现我没有在我的主Nginx配置文件中设置字符集:
http {
charset utf-8;
}
通过添加上面的内容,问题消失了,我认为这是正确的处理这个问题的方法。
When uploading files with non-ASCII characters I get UnicodeEncodeError:
Exception Type: UnicodeEncodeError at /admin/studio/newsitem/add/
Exception Value: 'ascii' codec can't encode character u'\xf8' in position 78: ordinal not in range(128)
See full stack trace.
I run Django 1.2 with MySQL and nginx and FastCGI.
This is a problem that is fixed according to the Django Trac database, but I still have the problem. Any suggestions on how to fix are welcome.
EDIT: This is my image field:
image = models.ImageField(_('image'), upload_to='uploads/images', max_length=100)
After investigating this some more I found out that I hadn't set the charset in my main Nginx config file:
http {
charset utf-8;
}
By adding the above, the problem disappeared and I think that this is the correct way of handling this issue.
这篇关于UnicodeEncodeError:'ascii'编解码器不能编码字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!