# views_send_code.py from rest_framework.permissions import AllowAny class MsgCodeViewSet(CreateModelMixin, viewsets.GenericViewSet): serializer_class = MsgCodeSerializer
pagination_class = StandardResultsSetPagination # 认证策略属性
authentication_classes = ()
# 权限策略属性
permission_classes = (AllowAny, )
解决问题:不用登录,就可以访问api
其他:
#permission是用来做权限判断的
# IsAuthenticated:必须登录用户;IsOwnerOrReadOnly:必须是当前登录的用户
permission_classes = (IsAuthenticated,IsOwnerOrReadOnly)