我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用rest_framework.decorators.permission_classes()。
def get_permissions(self): if self.action in ('create',): self.permission_classes = [IsAuthenticated] return [permission() for permission in self.permission_classes] # [GET] api/shares/
def wrap_as_django_rest_framework_view(cls, *args, **kwargs): view = cls.as_view(*args, **kwargs) view = permission_classes((IsAuthenticated,))(view) view = authentication_classes(cls.get_view_authentication_classes())(view) view = api_view(['POST', 'GET'])(view) return view
def as_view(cls, *args, **kwargs): view = super(DRFAuthenticatedGraphQLView, cls).as_view(*args, **kwargs) view = permission_classes((IsAuthenticated,))(view) view = authentication_classes(api_settings.DEFAULT_AUTHENTICATION_CLASSES)(view) view = api_view(['GET', 'POST'])(view) return view