我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用rest_framework.permissions.BasePermission()。
def isDjangoGroupMember(group_name): ''' Dynamically creates a permission class for the specified group, for use in class-based DRF views ''' class IsDjangoGroupMember(permissions.BasePermission): def has_permission(self, request, view): try: in_group_or_403(request.user, group_name) return True except: return False return IsDjangoGroupMember