On Tue, Apr 9, 2013 at 9:54 AM, Netavid dotorg <neta...@gmail.com> wrote:
> Hi All,
>
>   I have a Book table in MySQL db.
>   I configured my MySQL db and table to use utf8 character set and the
> utf8_general_ci collation
>   I created a simple Book class and tried to save unicode data using (a)the
> django shell  (b)  the data entry screen created by using ModelAdmin class
>
>   In both cases  I was getting errors.  The column in the model class is
> defined as having Charfield.
>
>   I checked this link https://docs.djangoproject.com/en/1.5/ref/unicode/. I
> tried to use smart_text function. But it did not work.
>   I am using python 2.7, django1.5, mysql 5x  in windows box
>   The text I am trying to save is a devanagari script word (wikipedia lang
> code "hi").
>   Below are the error messages.
>   can some one please help.
>
> regards
>

You're giving django byte strings. Give it unicode instead:

'This is a bytestring'
u'This is unicode text'

If you are only using ascii, then Django will not care about the
difference between a byte string and a unicode string. If you are not,
python will attempt to convert it to unicode, and often fail.

Whether it fails or not depends upon the encoding of the string, the
locale you are running in, but that is not relevant - provide all your
data as unicode strings and django will DTRT.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to