zoukankan      html  css  js  c++  java
  • 10 Django RESTful api 实现匿名访问

    # 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)
  • 相关阅读:
    事务,视图,索引
    SQL 编辑
    相关子查询
    4
    3
    2
    1
    BaseEditor
    EDCheckPrefabRef
    UIUseImgWindow
  • 原文地址:https://www.cnblogs.com/pgxpython/p/10683312.html
Copyright © 2011-2022 走看看