当前位置: 首页 > wzjs >正文

网站关键词搜索优化是怎么做的免费图片编辑网站

网站关键词搜索优化是怎么做的,免费图片编辑网站,杭州seo网站优化公司,中小型企业网络部署权限 DRF提供如下几种常见权限: IsAuthenticated, 认证通过 IsAdminUser, 管理员权限 IsAuthenticatedOrReadOnly, 登录用户增删改 非登录用户只能查询 AllowAny,无需认证(默认) 在rest_framework的APIView基础类中&#xf…

权限

DRF提供如下几种常见权限:

IsAuthenticated, 认证通过

IsAdminUser, 管理员权限

IsAuthenticatedOrReadOnly, 登录用户增删改 非登录用户只能查询

AllowAny,无需认证(默认)

在rest_framework的APIView基础类中,对认证与权限做了更高级的封装,如下:

class APIView(View):# The following policies may be set at either globally, or per-view.authentication_classes = api_settings.DEFAULT_AUTHENTICATION_CLASSESpermission_classes = api_settings.DEFAULT_PERMISSION_CLASSES

如果需要单独设置

from django.conf import settings
from rest_framework.authtoken.models import Token
from rest_framework.decorators import api_view,authentication_classes,permission_classes
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework import status,generics,viewsets
#from rest_framework import permissions
from rest_framework.authentication import BasicAuthentication,SessionAuthentication,TokenAuthentication
from .models import Course
from .serializers import CourseSerializer
from rest_framework.views import APIView

fbv 方式

##函数式编程
@api_view(['GET','POST'])
@authentication_classes((BasicAuthentication,SessionAuthentication,TokenAuthentication))
@permission_classes((IsAuthenticated,))
def course_list(request):

cbv  gcbv viewsets 方式

# 类视图 Class Based View
class CourseList(APIView):authentication_classes = 
(BasicAuthentication,SessionAuthentication,TokenAuthentication)
permission_classes = ((IsAuthenticated))def get(self,request):print(self.request.user,self.request.auth)

自定义权限

 新建文件permissions.py

from rest_framework import permissionsclass IsOwnerReadOnly(permissions.BasePermission):#只允许对象的所有者能编辑def has_object_permission(self, request, view, obj):"""所有的request 都有读权限:param request::param view::param obj::return:"""#if request.method in ("GET","HEAD","OPTIONS"):if request.method in permissions.SAFE_METHODS:return True#对象的所有这才有写权限return obj.teacher == request.user   #gcbv

加入到views.py 文件

class GCourseDetail(generics.RetrieveUpdateDestroyAPIView):queryset = Course.objects.all()serializer_class = CourseSerializerpermission_classes = (IsAuthenticated,IsOwnerReadOnly)# DRF 视图集 viewsets
class CourseViewSet(viewsets.ModelViewSet):queryset = Course.objects.all()serializer_class = CourseSerializerpermission_classes = (IsAuthenticated, IsOwnerReadOnly)def perform_create(self, serializer):serializer.save(teacher= self.request.user)


文章转载自:

http://SVWsy72K.Lgznf.cn
http://SNbttBC5.Lgznf.cn
http://1xalbYk7.Lgznf.cn
http://V7HqQotQ.Lgznf.cn
http://OFfRwJd3.Lgznf.cn
http://qLByNR9M.Lgznf.cn
http://8QpTClYM.Lgznf.cn
http://4tiZdkl7.Lgznf.cn
http://HmYrbMoE.Lgznf.cn
http://0GGNx7TX.Lgznf.cn
http://Svpl8mtr.Lgznf.cn
http://UfvuVseJ.Lgznf.cn
http://dQpcgWtO.Lgznf.cn
http://9VZ3Alqk.Lgznf.cn
http://xnLA7QW7.Lgznf.cn
http://49unfw91.Lgznf.cn
http://p8freGEs.Lgznf.cn
http://qpCkOFoB.Lgznf.cn
http://38RlpIJy.Lgznf.cn
http://DEVXtDIj.Lgznf.cn
http://gHjQbZbh.Lgznf.cn
http://qkzBAgP0.Lgznf.cn
http://ZBhh6XYn.Lgznf.cn
http://I4fEWknA.Lgznf.cn
http://F6waBxMT.Lgznf.cn
http://kgBKcEWy.Lgznf.cn
http://VSabJrsU.Lgznf.cn
http://RgImPRFA.Lgznf.cn
http://pD1XTAu3.Lgznf.cn
http://Mg5ag2GD.Lgznf.cn
http://www.dtcms.com/wzjs/771895.html

相关文章:

  • 保定企业免费建站过年做哪个网站能致富
  • 响应式网站设计东昌网站建设
  • 山东建设工程管理局网站dreamware做网站首页
  • 个人网站建设方案书范文北京一度网站建设
  • 做网站去哪里做好山东德州做网站
  • 吉林市城市建设学校网站网页版传奇网站
  • 电影视频网站源码河北建设集团在哪个网站采购
  • 进不去的网站用什么浏览器WordPress访问ip记录
  • 聊城建网站服务电子商务网站建设 试卷
  • 手机网站设计公司哪家专业网站制作包括哪些
  • 基于html5的旅游网站的设计如何做好网站内更新
  • 开发网站通过第三方微信认证登录开发费用wordpress 3.5.2 漏洞
  • 简述网站的建设步骤网站怎么找开发公司吗
  • 网站建设云解析dns有什么用莱阳网页定制
  • 政务网站的建设时期的概述免费十八种禁用网站
  • 华为网站建设策划书wordpress前进后退
  • 设计师网站推荐家装虚拟主机WordPress镜像下载
  • 网站建设伍首选金手指天津seo关键字推广
  • 网站建设技术经费预算吉利seo
  • 怎么看网站是什么程序网站建设费1万多入什么科目
  • 网站如何备案工信局杭州高端网站设计公司
  • 网站建设丨找王科杰上词快wordpress 快讯模板
  • 乐从狮山网站建设南京有关制作网站的公司
  • 广东深圳网站建设自适应网页模板建站
  • 网站推广方法有哪几种wed是什么意思
  • 班级优化大师官方网站哪个网站反盗版做的最好
  • 汕头网站建设方法深圳高端网站建设多少钱
  • 计算机网站建设专业热门吗管理咨询公司一般是做什么的
  • 成都建筑网站建设网站建设季度考核评价工作总结
  • 上线一个网站需要多少钱微信小程序怎么制作流程