... | ... | @@ -177,7 +177,7 @@ view = MyGeneric.as_view() |
|
|
|
|
|
[Official DRF documentation about viewsets](https://www.django-rest-framework.org/api-guide/viewsets/)
|
|
|
|
|
|
To go even further in the automation of exposing Django's model, DRF uses viewsets. The goal of a standard Django's viewset is to group similar view together to make the code more understandable while avoiding duplication of code. In the context of API, a very common use of viewsets is to expose a model by providing one URL to act on the whole queryset (list and create objects) and another URL to act on each of the objects (details, edit, delete). To automate that, DRF provides sone viewsets that handles nearly everything by grouping some pre-defined generics together:
|
|
|
To go even further in the automation of exposing Django's model, DRF uses viewsets. The goal of a standard Django's viewset is to group similar view together to make the code more understandable while avoiding duplication of code. In the context of API, a very common use of viewsets is to expose a model by providing one URL to act on the whole queryset (list and create objects) and another URL to act on each of the objects (details, edit, delete). To automate that, DRF provides some viewsets that handle nearly everything by grouping some pre-defined generics together:
|
|
|
|
|
|
* **ModelViewSet**: Exposes a Django's model by providing two URL:
|
|
|
* *\<url_base\>/*: use GET and POST method to edit the whole queryset
|
... | ... | |