I have pulled together pieces to do this. I posted about it here: http://blog.michaeltrier.com/2007/7/30/json-generic-serializer
I don't know if it's exactly what you're looking for, but check it out. Empty On 7/26/07, Eric St-Jean <[EMAIL PROTECTED]> wrote: > > Hi, > There does not seem to be an easy way to serialize anything to JSON: > serializers.serialize will handle a QuerySet > simplejson.dumps will handle normal python data structures > > But what about a python dict which has a django model instance in it, > for example??? Or a Field? > > Sure, i can (and did) write a trivial recursive function (it was a hack, > i should make it a proper serializer) which looks into the structure and > loops into the elements. > upon finding a list or dict or tuple, it calls itself. > Finding a queryset it calls serializers.serialize > Finding a base python type it calls simplejson.dumps > Finding a model instance, i made a stupid quick hack to get a queryset > which has that instance only, and then i call serializers.serialize on it. > > But i can hardly believe i'm the first one with this problem; did anyone > make a generic serializer, which will handle both python stuff and > django stuff (not just QuerySets)??? > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---