Simple function to return json in Django
Wed 22 February 2012
Just a small code snippet I use when I need to return json, comments are welcomed.
from django.http import HttpResponse
from django.utils import simplejson as json
def json_response(dict_to_convert_to_json):
return HttpResponse(json.dumps(dict_to_convert_to_json),
mimetype="application/json")
To use it in your view you just do it this …
Continue reading »