I never got that to work either - here´s how I´m dealing with it:

import django.utils.simplejson as simplejson

data = []
        ...
        try:
                school_list = School.objects.filter(...)
                for school in school_list:
                        school_info = school.name.decode('utf-8') + " / " +  
school.address.decode('utf-8')
                        data.append([school.id, school_info])
        ...
        jsonList = simplejson.dumps((data))
...
return HttpResponse(jsonList)


patrick

Am 02.11.2006 um 18:12 schrieb olive:

>
> Hello,
>
> I'm trying to send som UTF-8 data this way:
>
> json = serializers.serialize("json", myQuerySet, ensure_ascii=False)
> return HttpResponse(json, mimetype="text/javascript; charset=UTF-8")
>
> But the accented characters are not displayed properly in the browser.
>
>
> But if I put this on the first line of my views.py:
>
> # -*- coding: UTF-8 -*-
>
> and I try to send hard coded data this way:
>
>     json = '[{"pk": "1", "model": "body.datacontent", "fields":
> {"content": "Heading à 1", "type": "hdg"}},{"pk": "2", "model":
> "body.datacontent", "fields": {"content": "Para 1", "type": "par"}}]'
>
> Then "Heading à 1" is properly displayed in the browser.
>
>
> Question: am I using serializers.serialize the right way or is it
> broken ?
>
> Note: my database is UTF-8 encoded too (I have tested that by
> extracting an accented string from it and displaying it in the
> browser).
>
> Olive
>
>
> >


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

Reply via email to