With Django Class-based views you can write:
from django.views import View from django.http import JsonResponse class JsonView(View): def get(self, request): return JsonResponse({'some': 'data'}) and with Django-Rest-Framework you can write:
from rest_framework.views import APIView from rest_framework.response import Response class JsonView(APIView): def get(self, request): return Response({'some': 'data'})