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


also add to django.wsgi:

import sys

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


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