# 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)

 

相关文章:

  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-06
猜你喜欢
  • 2021-10-30
  • 2021-07-02
  • 2022-12-23
  • 2021-06-28
  • 2021-09-10
相关资源
相似解决方案