On Sun, Jun 1, 2008 at 9:16 AM, Stephen Cheng <[EMAIL PROTECTED]>
wrote:

>
> I got exception in admin page when I input chinese character into one
> field and try to save to db. I am not sure which lib I should install
> to make it work or any configure I should enable.
>
> Any advice?
>
>
You need to implement a __unicode__ method for your model:

http://www.djangoproject.com/documentation/model-api/#unicode

Karen

>
>
> UnicodeEncodeError at /admin/books/author/add/
> 'ascii' codec can't encode characters in position 0-2: ordinal not in
> range(128)
> Request Method:         POST
> Request URL:    http://192.168.1.166:1920/admin/books/author/add/
> Exception Type:         UnicodeEncodeError
> Exception Value:        'ascii' codec can't encode characters in position
> 0-2: ordinal not in range(128)
> Exception Location:     /home/stephen/python-lib/lib/python2.5/site-
> packages/django/utils/encoding.py in force_unicode, line 53
> Python Executable:      /home/stephen/python-lib/bin/python
> Python Version:         2.5.2
> Python Path:    [''/home/stephen/python-lib/lib/python2.5/site-packages/
> setuptools-0.6c8-py2.5.egg', '/home/stephen/python-lib/lib/
> python25.zip', '/home/stephen/python-lib/lib/python2.5', '/home/
> stephen/python-lib/lib/python2.5/plat-freebsd7', '/home/stephen/python-
> lib/lib/python2.5/lib-tk', '/home/stephen/python-lib/lib/python2.5/lib-
> dynload', '/home/stephen/python-lib/lib/python2.5/site-packages', '/
> home/stephen/python-lib/lib/python2.5/site-packages/Numeric', '/home/
> stephen/python-lib/lib/python2.5/site-packages/PIL', '/home/stephen/
> python-lib/lib/python2.5/site-packages/gtk-2.0', '/usr/local/lib/
> python2.5/site-packages', '/usr/local/lib/python2.5/site-packages/
> Numeric', '/usr/local/lib/python2.5/site-packages/PIL', '/usr/local/
> lib/python2.5/site-packages/gtk-2.0']
> Server time:    Sun, 1 Jun 2008 08:07:24 -0500
>
>
> Environment:
>
> Request Method: POST
> Request URL: http://192.168.1.166:1920/admin/books/author/add/
> Django Version: 0.97-pre-SVN-7568
> Python Version: 2.5.2
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'TestSite.books',
>  'django.contrib.admin']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.middleware.doc.XViewMiddleware')
>
>
> Traceback:
> File "/home/stephen/python-lib/lib/python2.5/site-packages/django/core/
> handlers/base.py" in get_response
>  82.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "/home/stephen/python-lib/lib/python2.5/site-packages/django/
> contrib/admin/views/decorators.py" in _checklogin
>  62.             return view_func(request, *args, **kwargs)
> File "/home/stephen/python-lib/lib/python2.5/site-packages/django/
> views/decorators/cache.py" in _wrapped_view_func
>  44.         response = view_func(request, *args, **kwargs)
> File "/home/stephen/python-lib/lib/python2.5/site-packages/django/
> contrib/admin/views/main.py" in add_stage
>  266.             LogEntry.objects.log_action(request.user.id,
> ContentType.objects.get_for_model(model).id, pk_value,
> force_unicode(new_object), ADDITION)
> File "/home/stephen/python-lib/lib/python2.5/site-packages/django/
> utils/encoding.py" in force_unicode
>  53.                 s = unicode(str(s), encoding, errors)
>
> Exception Type: UnicodeEncodeError at /admin/books/author/add/
> Exception Value: 'ascii' codec can't encode characters in position
> 0-2: ordinal not in range(128)
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to