Difference between APIView class and viewsets class?

前端 未结 4 1308
死守一世寂寞
死守一世寂寞 2021-02-03 22:36

What are the difference between APIView class and viewsets class ? I am following Django REST-framework official documentation. I think it lac

4条回答
  •  一生所求
    2021-02-03 23:12

    The functions you add to the APIView are different than the functions you add to the ViewSet class.

    • APIView: you add functions for the particular HTTP method you want to support on your endpoint. Ex: GET, POST, PUT, PATCH, DELETE

    • ViewSet: you would add functions that represent actions that you'd perform on a typical API. Ex: LIST, CREATE, RETRIEVE, UPDATE

提交回复
热议问题