On Thu, May 19, 2011 at 1:23 PM, Jonas Geiregat <[email protected]> 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 [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.