when my url contains utf-8 characters such as chinese, it's occurs an UnicodeEncodeError

54 views
Skip to first unread message

VespertineR Lau

unread,
Nov 23, 2009, 10:15:43 PM11/23/09
to Django users
when my url contains utf-8 characters such as chinese, it's occurs an
UnicodeEncodeError:




UnicodeEncodeError at /upload/snap/屏幕快照_2009-11-19_下午09.54.12.png

'ascii' codec can't encode characters in position 39-42: ordinal not
in range(128)

Request Method: GET
Request URL:
http://192.168.10.220:8000/upload/snap/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7_2009-11-19_%E4%B8%8B%E5%8D%8809.54.12.png
Exception Type: UnicodeEncodeError
Exception Value:

'ascii' codec can't encode characters in position 39-42: ordinal not
in range(128)

Exception Location: /usr/lib/python2.4/site-packages/django/views/
static.py in serve, line 51
Python Executable: /usr/local/bin/python
Python Version: 2.4.4
Python Path: ['/home/vinnie/django/mysite', '/usr/lib/python24.zip',
'/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/
python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/local/lib/
python2.4/site-packages', '/usr/lib/python2.4/site-packages', '/usr/
lib/python2.4/site-packages/PIL', '/var/lib/python-support/python2.4']





Environment:

Request Method: GET
Request URL:
http://192.168.10.220:8000/upload/snap/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7_2009-11-19_%E4%B8%8B%E5%8D%8809.54.12.png
Django Version: 1.1.1
Python Version: 2.4.4
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'mysite.helloworld']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py"
in get_response
92. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/lib/python2.4/site-packages/django/views/static.py" in
serve
51. if os.path.isdir(fullpath):

Exception Type: UnicodeEncodeError at /upload/snap/屏幕快照_2009-11-19_下午
09.54.12.png
Exception Value: 'ascii' codec can't encode characters in position
39-42: ordinal not in range(128)









can anyone help~? thanks~ my wrong system setting or wrong django
setting~?

Karen Tracey

unread,
Nov 23, 2009, 11:10:31 PM11/23/09
to django...@googlegroups.com
2009/11/23 VespertineR Lau <vespert...@gmail.com>
when my url contains utf-8 characters such as chinese, it's occurs an
UnicodeEncodeError:

[snip]

Traceback:
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py"
in get_response
 92.                 response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/lib/python2.4/site-packages/django/views/static.py" in
serve
 51.     if os.path.isdir(fullpath):

Exception Type: UnicodeEncodeError at /upload/snap/屏幕快照_2009-11-19_下午
09.54.12.png
Exception Value: 'ascii' codec can't encode characters in position
39-42: ordinal not in range(128)


This generally indicates an incorrect LANG setting for Apache.  See:

http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-you-get-a-unicodeencodeerror

Karen
Reply all
Reply to author
Forward
0 new messages