class MyView(View):

    def get(self, request):
        my_data = {'something': 'some value'}
return JsonResponse(my_data, mimetype='application/json')
Django REST API with multiple representations/formats