The create/retrieve/update/delete operations that we've been using so far are going to be pretty similar for any model-backed API views we create. Those bits of common behaviour are implemented in REST framework's mixin classes.

    We'll take a moment to examine exactly what's happening here. We're building our view using GenericAPIView, and adding in ListModelMixin and CreateModelMixin.

    1. class SnippetDetail(mixins.RetrieveModelMixin,
    2. mixins.DestroyModelMixin,
    3. generics.GenericAPIView):
    4. serializer_class = SnippetSerializer
    5. def get(self, request, *args, **kwargs):
    6. return self.retrieve(request, *args, **kwargs)
    7. return self.update(request, *args, **kwargs)
    8. def delete(self, request, *args, **kwargs):

    Pretty similar. Again we're using the GenericAPIView class to provide the core functionality, and adding in mixins to provide the .retrieve(), .update() and .destroy() actions.