UnicodeEncodeError: 'ascii' codec can't encode character

前端 未结 12 821
予麋鹿
予麋鹿 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 20:47

    For anyone encountering this problem when running Django with Supervisor, the solution is to add e.g. the following to the supervisord section of Supervisor's configuration:

    environment=LANG="en_US.utf8", LC_ALL="en_US.UTF-8", LC_LANG="en_US.UTF-8"
    

    This solved the problem for me in Supervisor 3.0a8 running on Debian Squeeze.

    Also make sure Supervisor re-reads the configuration by running:

    supervisorctl reread
    supervisorctl restart myservice
    

    (thanks @Udi)


    For upstart, add in your /etc/init/myservice.conf:

    env LANG="en_US.utf8"
    env LC_ALL="en_US.UTF-8"
    env LC_LANG="en_US.UTF-8"`
    

    (thanks @Andrii Zarubin; see Environment Variables in Upstart documentation for more information)

提交回复
热议问题