U
U
un1t2012-10-04 17:16:23
Django
un1t, 2012-10-04 17:16:23

UnicodeEncodeError on Apache2 with mod_wsgi on Debian lenny?

There is a model in which there is an ImageField, in the admin panel in the display of the list of objects the file name and preview are displayed.
If I upload a file with Russian characters in the name, then when the list is displayed, I get a UnicodeEncodeError.
Apache is running as user www-data, which has all locales "en_US.UTF-8".
A Google search found a recommendation to write in /etc/apache2/envvars LANG="en_US.UTF-8" and LC_ALL="en_US.UTF-8". Tried it didn't help.
UDT:
Found that
1) crashes on line
st = os.stat(path)<br>
2) locale.getdefaultlocale() returns (None, None)
UDT2
Installed in django.wsgi

os.environ['LANG']='en_US.UTF-8'<br>
os.environ['LC_ALL']='en_US.UTF-8'<br>

After that, locale.getdefaultlocale() began to return ('en_US', 'UTF8')
However, sys.getdefaultencoding() returns 'ascii'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alternativshik, 2012-10-04
@alternativshik

Is the field in the database and the base exactly in utf-8?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question