2
I think the solution is to override get_object
– I hadn’t realise I could access the url parameters under the view class itself:
class Foo(generics.RetrieveDestroyAPIView):
serializer_class = FooSerializer
def get_object(self):
return Foo.objects.all()[self.kwargs['foo_if_in_url'] - 1]
Source:stackexchange.com