可以通过重写get_permissions方法和get_serializers_class方法来实现动态的配置权限和序列化
VIewDemo
class RegUserSet(mixins.CreateModelMixin,mixins.RetrieveModelMixin,viewsets.GenericViewSet): serializer_class = RegUserSerializer # permission_classes = () # queryset = User.objects.all() def get_permissions(self): if self.action == 'retrieve': return [IsAuthenticated()] else: return [] def get_serializer_class(self): pass def get_object(self): return self.request.user