1.基于BasePermission自定义权限
1.1 基于from rest_framework.permissions import BasePermission 实现权限
class App01Permission(BasePermission): def has_permission(self, request, view): ''' :param request: :param view: :return: 由于已经过了认证组件,request.user已经有值了。 ''' # print('认证模块') # print(self) # print(request) # print(view) user=request.user # print(user.get_usertype_display()) if user.usertype==1: return True else: raise PermissionDenied(detail='权限不足,滚回去',code=222)
标签:view,request,BasePermission,user,print,权限,DRF From: https://www.cnblogs.com/so-shuai/p/17330533.html