[Django]-Django UnicodeEncodeError, Apache2 with mod_wsgi on Debian lenny

5👍

also add to django.wsgi:

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

simple sys.setdefaultencoding(‘utf-8’) will not help, reload is important
This is python 2.x problem, not the django

0👍

Debian doesn’t I believe use ‘/etc/apache2/envvars’. Setting these values from inside of the Python script will not work as it will not initialise some things that only occur at process startup.

You either need to set the variables in the init.d startup script for Apache if envvars not consulted, or use mod_wsgi 3.4 and use daemon mode, setting the ‘lang’ and ‘locale’ options to WSGIDaemonProcess directive.

Leave a comment