zoukankan      html  css  js  c++  java
  • DRF的View方法

    APIView

    APIView与Django的View类似,我们的业务类只需要继承APIView,在URL传递过程,我们只需要调用APIView的as_view()方法,然后URL就会调用业务类对应的HTTP方法,如get,post,put,delete(对应查 增 改 删)方法,我们在业务代码中只需要实现三个功能即可实现get方法

    ORM调用
    序列化
    返回数据

    CreateAPIView

    需要写字符查询集 与 序列化器
    queryset = models.xx..
    serializer_class = form seializer im.....
    提供post方法处理程序。

    ListAPIView

    需要写字符查询集 与 序列化器
    queryset = models.xx..
    serializer_class = form seializer im.....
    用于只读端点以表示模型实例的集合。
    提供get方法处理程序。

    RetrieveAPIView

    需要写字符查询集 与 序列化器
    queryset = models.xx..
    serializer_class = form seializer im.....
    用于表示单个模型实例的只读端点。
    提供get方法处理程序。

    DestroyAPIView

    需要写字符查询集 与 序列化器
    queryset = models.xx..
    serializer_class = form seializer im.....
    用于单个模型实例的仅删除端点。
    提供delete方法处理程序。

    UpdateAPIView

    需要写字符查询集 与 序列化器
    queryset = models.xx..
    serializer_class = form seializer im.....
    用于单个模型实例的仅更新端点。
    提供put和patch方法处理程序。

    ListCreateAPIView

    需要写字符查询集 与 序列化器
    queryset = models.xx..
    serializer_class = form seializer im.....
    用于读写端点以表示模型实例的集合。
    提供get和post方法处理程序。

    RetrieveUpdateAPIView

    需要写字符查询集 与 序列化器
    queryset = models.xx..
    serializer_class = form seializer im.....
    用于读取或更新端点以表示单个模型实例。
    提供get,put并且patch方法处理。

    RetrieveDestroyAPIView

    需要写字符查询集 与 序列化器
    queryset = models.xx..
    serializer_class = form seializer im.....
    用于读取或删除端点以表示单个模型实例。
    提供get和delete方法处理程序。

    RetrieveUpdateDestroyAPIView

    需要写字符查询集 与 序列化器
    queryset = models.xx..
    serializer_class = form seializer im.....
    用于读写 - 删除端点以表示单个模型实例。
    提供get,put,patch和delete方法处理。

  • 相关阅读:
    swift 第三方库迁移错误解决“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choo
    ios 绘制虚线 CGContextSetLineDash的使用
    在 cell 中获取 textFlied内容的使用
    swift 委托代理传值
    swift3.0基础语法
    webSocket开源框架:SocketRocket 简单的使用
    iOS开发— Socket编程
    常见的 HTTP错误代码大全
    lambda表达式的使用
    浅谈静态代理模式 01
  • 原文地址:https://www.cnblogs.com/Gin1/p/14312649.html
Copyright © 2011-2022 走看看