我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用rest_framework.viewsets.ViewSet()。
def get_permissions(self): """Define custom permissions for different methods""" # at minimum require users to be authenticated self.permission_classes = [IsAuthenticated] # for PUT requests require users to be admins if self.request.method == 'PUT': self.permission_classes.append(IsAdminUser) return super(viewsets.ViewSet, self).get_permissions()