Hi ! I have written a small library that (among other transformations) can serialize django objects to dict (then you can just use 'json' to make your dict to a json string) :
Docs on readthedocs : http://readthedocs.org/docs/any2any/en/latest/doc_pages/djangocast.html Pypi page : http://pypi.python.org/pypi/any2any/0.1 You can achieve very easily the format you need. Please ask if you need help ! Cheers, Sébastien On May 19, 5:05 pm, Tom Evans <tevans...@googlemail.com> wrote: > On Thu, May 19, 2011 at 1:23 PM, Jonas Geiregat <jo...@geiregat.org> wrote: > > Hello, > > I'm also finding the built in serialization a bit overhead. > > Me too! I use a simple HttpResponse subclass for generating JSON though: > > from django.http import HttpResponse > from django.utils import simplejson > > class JsonResponse(HttpResponse): > def __init__(self, data): > super(JsonResponse, self).__init__(content=simplejson.dumps(data), > mimetype='application/json') > > Use it like this: > > return JsonResponse({'id': foo.id, 'some_list': [ 1,2,3,4 ]}) > > Cheers > > Tom -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.