Skip to content

Instantly share code, notes, and snippets.

@Allwin12
Last active November 23, 2020 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Allwin12/dd9e0ae1d0acc790794e312460eeb826 to your computer and use it in GitHub Desktop.
Save Allwin12/dd9e0ae1d0acc790794e312460eeb826 to your computer and use it in GitHub Desktop.
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework_xml.renderers import XMLRenderer
from student.models import School
from student.serializers import SchoolListSerializer
class SchoolView(APIView):
renderer_classes = [XMLRenderer, ]
def get(self, request):
schools = School.objects.all()
school_serializer = SchoolListSerializer(schools, many=True)
return Response(school_serializer.data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment