Nowadays the most popular deployment scenario for Django application is scenario with Nginx, Gunicorn and Supervisor. These scenarios are great for deployment, however there is still a risk of error: site is going down when you try upload any file with Cyrillic symbols in it’s name.
This problem can be solved in two steps:
On the first step we switch to Ukrainian/Russian locale in Debian (in Ubuntu and Ubuntu-based distributions the same commands). Execute a simple command:
dpkg-reconfigure locales and we got this window:
There is locale ru_RU.UTF-8 UTF-8 in the left column – check this option and go on the next step. Then you choose locale by default. Let’s choose this locale
Click OK, locale is generating and first step completed.
Step Two. Open Supervisor settings in
/etc/supervisor/. In the supervisord.conf file we need change environment:
[locales] environment=LANG="ru_RU.utf8", LC_ALL="ru_RU.UTF-8", LC_LANG="ru_RU.UTF-8"
Then reload services with command
service supervisor restart and
supervisorctl restart your_app_name. Check the upload file feature.
Great! Now everything is fine and no more errors with file names.