Python rest_framework.decorators 模块,permission_classes() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用rest_framework.decorators.permission_classes()

项目:django-rest-framework-tutorial    作者:twtrubiks    | 项目源码 | 文件源码
def get_permissions(self):
        if self.action in ('create',):
            self.permission_classes = [IsAuthenticated]
        return [permission() for permission in self.permission_classes]

    # [GET] api/shares/
项目:occasions-server    作者:travisbloom    | 项目源码 | 文件源码
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
项目:django-netbox-graphql    作者:ninech    | 项目源码 | 文件源码
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