我有一个通用视图集自定义操作,我只想从此操作中删除身份验证和权限类。我尝试了以下操作,但不起作用。
class ExampleView(GenericViewSet,
mixins.ListModelMixin,
mixins.DestroyModelMixin,
mixins.CreateModelMixin,
):
authentication_classes = [SessionAuthentication, BasicAuthentication]
permission_classes = [IsAuthenticated]
def custom_action(self, request, format=None):
self.authentication_classes = []
self.permission_classes = []
答案 0 :(得分:2)