On Sun, Oct 12, 2008 at 11:09 AM, kele <[EMAIL PROTECTED]> wrote:

>
> i am using the django 1.0 , and while i am try to post some data
> (japanes ,chinese characters) and insert to my Mysql db  , i got this
> error   . my table is create in utf8 character , and my setting.py
> already has the
> DEFAULT_CHARSET = 'utf-8' ,
>

DEFAULT_CHARSET doesn't really matter here since it has nothing to do with
the database or communicating with the database.  See:

http://docs.djangoproject.com/en/dev/ref/settings/#setting-DEFAULT_CHARSET

It's used for encoding HttpResponse objects, not for database communiction.


>
>
> where going wrong ?? i am getting MAD in this . HELP!
>
> Environment:
>
> Django Version: 1.0-final-SVN-unknown
> Python Version: 2.4.3
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.admin',
>  'mytest.shaft']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
>
> Traceback:
> [snip]
> File "build/bdist.linux-i686/egg/MySQLdb/connections.py" in
> unicode_literal
>  185.                 return
> db.literal(u.encode(unicode_literal.charset))
>
> Exception Type: UnicodeEncodeError at /admin/shaft/clothes/add/
> Exception Value: 'latin-1' codec can't encode characters in position
> 0-2: ordinal not in range(256)
>

This is odd.  MySQLdb appears to be using latin-1 for the connection
charset, yet Django always sets the connection charset to utf8, see:

http://code.djangoproject.com/browser/django/tags/releases/1.0/django/db/backends/mysql/base.py#L242

Somehow that is being overridden or is not working on your machine.  Have
you specified anything in DATABASE_OPTIONS in your settings.py?  What
version of MySQL are you using?

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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