Hi,

I have been using django for developing application and it went on fine, worked as expected, but was not handling unicode properly. I have a Post model, and I am fetching the content of some blog posts and storing it in Post in _pre_save. I was using
original_content = urllib.ulropen(self.url).read()
# beautiful soup over original_content, and get content to save
self.content = content_to_save
When I started making things unicode compliant, I did the following:
original_content = urllib.urlopen(self.url).read().decode('utf-8') # I am sure that self.url points a site that returns no
                                                                                        # encoding, thus I am assuming unicode.
# beautiful soup over original_content, and get content to save
self.content = content_to_save.encode('utf-8')
I am complete newbie to any unicode related app, I have defined Post.content as  meta.TextField(). And my went to phpMyAdmin and chenged the collation of database, table and row to be utf8_bin.

Things look fine, as I can see the post.content as proper unicode, hindi characters appearing in hindi fonts, when I am looking at some post in phpMyAdmin.

Now, my application suddenly went completely haywire, and I have narrowed the cause to this:
>>> p.partial_url
'/2006/01/introducing-labelr.html'
>>> p.partial_url = '' # i have to do this to force _pre_save to refetch the url
>>> p.save()
>>> type(p.content )
<type 'unicode'>
>>> p2 = posts.get_object(partial_url__exact = p.partial_url)
>>> p2 == p
True
>>> type(p2.content)
<type 'array.array'>
I am completely baffeled, please help me whats going on, or if I am doing unicode completely wrong.

--
Amit Upadhyay
Blog: http://www.rootshell.be/~upadhyay
+91-9867-359-701
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django developers" 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-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to