Return to Snippet

Revision: 21843
at December 22, 2009 15:02 by magicrebirth

Initial Code
def json_response(something):
    from django.utils import simplejson
    return HttpResponse(simplejson.dumps(something),
                        content_type='application/json; charset=UTF-8')

Initial URL

Initial Description
This function takes anything which can be dumped into JSON and returns an HTTP response of it, with the right Content-type header.

Initial Title
Django and JSON

Initial Tags
json, django

Initial Language