Re: Why serializing to JSON doesn't work?

2009-03-06 Thread Jeff FW
Keep the way you're serializing the querysets, add each one to a dictionary, and then: return dict((k, simplejson.dumps(v)) for k, v in ret_val.iteritems()) -Jeff On Mar 6, 10:49 am, Marek Wawrzyczek wrote: > Thanks for your responses, they helped :) > > In the code

Re: Why serializing to JSON doesn't work?

2009-03-06 Thread Marek Wawrzyczek
Thanks for your responses, they helped :) In the code below: ret['b'] = State.objects.all() print 'ret: %' % ret try: serialized = encoder.JSONEncoder().encode(ret) except Exception, e: print 'exception: %s' % e I was

Re: Why serializing to JSON doesn't work?

2009-03-05 Thread Jeff FW
You know what's weird? I've used simplejson.dumps() plenty of times in my own code... not sure why that one just slipped out of my memory. I should just stop responding to things :-) Anyway, since you're serializing a model, you *should* be using your originally posted method. Use the way

Re: Why serializing to JSON doesn't work?

2009-03-05 Thread Marek Wawrzyczek
Thomas Guettler wrote: > > Jeff FW schrieb: > >> The serializers are for serializing querysets/models. I'm surprised >> you're not getting an error message there--are you catching all >> exceptions? >> >> What you want is in django.utils.simplejson: >> >> from django.utils.simplejson import

Re: Why serializing to JSON doesn't work?

2009-03-04 Thread Thomas Guettler
Jeff FW schrieb: > The serializers are for serializing querysets/models. I'm surprised > you're not getting an error message there--are you catching all > exceptions? > > What you want is in django.utils.simplejson: > > from django.utils.simplejson import encoder >

Re: Why serializing to JSON doesn't work?

2009-03-04 Thread Jeff FW
The serializers are for serializing querysets/models. I'm surprised you're not getting an error message there--are you catching all exceptions? What you want is in django.utils.simplejson: from django.utils.simplejson import encoder encoder.JSONEncoder().encode(ret) -Jeff On Mar 4, 6:55 pm,

Why serializing to JSON doesn't work?

2009-03-04 Thread Marek Wawrzyczek
Hello, I've got the code like this: from django.core import serializers ... ret = { } ret['a'] = 'b' json_serializer = serializers.get_serializer("json")() serialized = json_serializer.serialize(ret, ensure_ascii=False) print serialized and this doesn't print