Source

gnocchi-ajax / gnocchi / ajax / http.py

Full commit
from django.http import HttpResponse
from django.conf import settings
from .serialiser import JSONEncoder

ENCODER = JSONEncoder()

class JsonResponse( HttpResponse ):
    '''Utility class to simplify returning JSON responses'''
    def __init__(self, content =None, *args, **kw):
        if not settings.DEBUG:
            kw.setdefault('content_type', 'application/json')
        HttpResponse.__init__(self, ENCODER.encode(content), *args, **kw)