Last active
December 25, 2019 08:58
-
-
Save philippeowagner/3179eb475fe1795d6515 to your computer and use it in GitHub Desktop.
JsonResponse for Django<=1.6, included in Django >= 1.7 https://docs.djangoproject.com/en/dev/ref/request-response/#jsonresponse-objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.utils import simplejson | |
from django.http import HttpResponse | |
class JsonResponse(HttpResponse): | |
""" | |
JSON response | |
""" | |
def __init__(self, content, mimetype='application/json', status=None, content_type=None): | |
super(JsonResponse, self).__init__( | |
content=simplejson.dumps(content), | |
mimetype=mimetype, | |
status=status, | |
content_type=content_type, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you so much for this. Unfortunately I can't upgrade my company's Django version so this will have to do