Skip to main content
added 1 character in body
Source Link
elim
  • 1.6k
  • 1
  • 18
  • 19

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'}) 

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'}) 

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'}) 
Source Link
elim
  • 1.6k
  • 1
  • 18
  • 19

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'})