UnicodeEncodeError: 'ascii' codec can't encode character

前端 未结 12 806
予麋鹿
予麋鹿 2020-11-30 20:31

When uploading files with non-ASCII characters I get UnicodeEncodeError:

Exception Type: UnicodeEncodeError at /admin/studio/newsitem/add/
Exception Value: \         


        
12条回答
  •  北海茫月
    2020-11-30 21:13

    Using python 2.7.8 and Django 1.7, I solved my problem by importing:

    from __future__ import unicode_literals
    

    and using force_text():

    from django.utils.encoding import force_text
    

提交回复
热议问题