1, inherited from APIView
2, the method provides function
3 is used to define the class and attributes queryset serializer_class, after the method using the corresponding
queryset: indicates that the current view of data processing data sets to use the default
serializer_class: indicates that the current view of the data processing using the default class sequence
lookup_field = 'pk': The default value is 'pk', pk filter based on field
lookup_url_kwarg = 'id': extracting parameters field in the packet according to the instructions, the default is lookup_field
patch中get_serializer(book,data=book_info,partial=True)
This will update a field, do not pass must pass all parameters can be updated
4, five extension class
from rest_framework.mixins import ListModelMixin,CreateModelMixin
ListModelMixin inside the list method: Serialized return multiple pieces of data, inherited from the object; see the source code, the use of get_queryset method, not inherited, it is to use the method. get request
CreateModelMixin which create method: New stored data; POST request
RetrieveModelMixin inside retrieve methods: single sequence of data objects; get request
UpdateModelMixin inside update method: full update; PUT request
partial_update: updating part; Patch Request
destroyModelMixin inside the destroy method and perform_destroy: Remove; delete request
5, five subclasses
ListAPIView (mixins.ListModelMixin, GenericAPIView): get the list method invocation method, a sequence of a plurality of data returned in response to a GET request
CreateAPIView (mixins.CreateModelMixin, GenericAPIView): post method calls the create method, new data, in response to the POST request
RetrieveAPIView (mixins.RetrieveModelMixin, GenericAPIView): get method calls retrieve method returns a single sequence of data, in response to a GET request
UpdateAPIView (mixins.UpdateModelMixin, GenericAPIView): put method update method is called, all the corresponding data updating, in response to the PUT request
method calls partial_update patch method, part of the update data, in response to the request patch
DestroyAPIView (mixins.DestroyModelMixin, GenericAPIView): delete method calls destroy method, a single data delete, delete request response
Note: there is a single data filtration parameter, default PK (primary key id)