Django REST Framework - Different permission per methods within same view

Viewed 2895

So I've seen a couple of questions here on SO which are similar, but not quite what I'm looking for.

I'm trying to have different permissions per method within the same view. What I currently have:

class MyViewSet(viewsets.ViewSet):
    # User must be authenticated
    permission_classes = (IsAuthenticated,)

    def list(self, request):
        ...

    # User must be admin
    def create(self, request):
        ...

    def retrieve(self, request):
        ...

Basically I'm trying to ensure that only admins can call the create method. I've looked at creating custom permissions, but that applies accross the viewset, which is not quite what I want.

2 Answers
Related