Cyrillic symbols with uploaded in django filenames issue
April 6, 2016, 4:04 p.m. Category object TeamMember object

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 ru_RU.UTF-8 UTF-8.

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:

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.

About the author
client name
TeamMember object Formerly a graduate from the University, Sergey provides brilliant technical support to our projects. He’s a meticulous coder who’s all about the details.