from rest_framework.permissions import BasePermission class UserPermission(BasePermission): message = '不是超级用户,查看不了' def has_permission(self, request, view): # user_type = request.user.get_user_type_display() # if user_type == '超级用户': user_type = request.user.user_type print(user_type) if user_type == 1: return True else: return False class Course(APIView): authentication_classes = [TokenAuth, ] permission_classes = [UserPermission,] def get(self, request): return HttpResponse('get') def post(self, request): return HttpResponse('post')
drf视图组件
猜你喜欢
转载自blog.csdn.net/qq_38746842/article/details/89138036
今日推荐
周排行