Posted By

magicrebirth on 12/22/09


Tagged

json django


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

leachypeachy
sapphiriq
pjv
eliluminado


Django and JSON


 / Published in: Django
 

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

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

Report this snippet  

You need to login to post a comment.