Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django, nginx, gunicorn,supervisor: UnicodeEncodeError - when uploading non-latin named file

When I upload some files with non-latin names I got error:

UnicodeEncodeError at /profiles/
'ascii' codec can't encode characters in position 39-41: ordinal not in range(128)

I've tried change supervisor environment how it's described here, but it didn't help. I've added this line in /etc/supervisor/supervisord.conf:

[supervisord]
environment=LANG="ru_RU.utf8", LC_LANG="ru_RU.UTF-8", LC_ALL="ru_RU.UTF-8"
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)

When I put this line in program specific conf file it did not begin working too.

I've tried figure out my encoding, so I've add to template context this variable:

context['locale'] = sys.getfilesystemencoding()

and in template it shows "ANSI_X3.4-1968"

Could please someone explain why changing environment did not solve the problem?

like image 226
Sergey Cherepanov Avatar asked Jan 17 '26 22:01

Sergey Cherepanov


1 Answers

Make sure you have completely restarted supervisord, as described here. Hope it helps!

like image 151
Psion Avatar answered Jan 21 '26 00:01

Psion