For XML is works fine. BUT not JSON.
------------------------------
def left(request):

     query = Talk.objects.filter(side=2, talk_topic
=1).order_by('pub_date')[0:30]
     json_serializer = serializers.get_serializer("json")()
     data = json_serializer.serialize(query,
ensure_ascii=False,fields=('content'))
     return HttpResponse(data, "charset=UTF-8")
-----------------------------
UnicodeEncodeError at /Talk/Left 'ascii' codec can't encode characters in
position 1-2: ordinal not in range(128)
Unicode error hint

The string that could not be encoded/decoded was: *"不好"*
-------------------------------------------------------------------


On Wed, May 21, 2008 at 4:11 PM, Russell Keith-Magee <[EMAIL PROTECTED]>
wrote:

>
> On Wed, May 21, 2008 at 3:15 PM, ERic ZoU <[EMAIL PROTECTED]> wrote:
> >
> > It works in XML, but not JSON
> >
> > On May 21, 2:48 pm, ERic ZoU <[EMAIL PROTECTED]> wrote:
> >>      query = Talk.objects.filter(side=2, talk_topic
> >> =1).order_by('pub_date')[0:30]
> >>      data =  serializers.serialize('json', query, ensure_ascii=False,
> >> fields=('content'))
> >>      return HttpResponse(data, "charset=UTF-8")
> >>
> >> On May 21, 2:39 pm, ERic ZoU <[EMAIL PROTECTED]> wrote:
> >>
> >> > Exception Value:        'ascii' codec can't encode characters in
> position
> >> > 1-2: ordinal not in range(128)
> >>
> >> > My content is UTF-8 encode. Seems doesn't work.
>
> It works fine. You need to read the documentation.
>
> http://www.djangoproject.com/documentation/serialization/#id1
>
> Yours,
> Russ Magee %-)
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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