[Solved]-DRF – Method 'GET' not allowed

11👍

You’re getting this error because the DRF APIView doesn’t have a get method (or a method for any HTTP request type actually).To get your code working you can either rename your get_object method to get (making sure you add the expected parameters request and format), or you can write a get method to return your response:

class TESTXMLDetail(APIView):
    def get(self, request, pk, format=None):
        return self.get_object(pk)

    def get_object(self, pk):
        ...
        ...

Leave a comment