← Fullstack with Vue.jsQuestion 2 of 62
What are the standard methods in a Django REST Framework ViewSet and their corresponding HTTP methods?
📘 Explanation
The correct mapping is list() for GET on a collection, retrieve() for GET on a single item, create() for POST, update() for PUT, partial_update() for PATCH, and destroy() for DELETE, which matches DRF's standard ViewSet conventions. The other options rename these methods incorrectly (like detail() or remove()), swap PUT and PATCH between update() and partial_update(), or use Rails-style naming such as index(), show(), and store() that don't apply to DRF.
Related questions
- What types of API versioning does Django REST Framework support?
- In Django REST Framework ViewSets, which decorator is used to create a custom endpoint?
- How can you restrict which queryset a DRF view uses?
- Where do the values in request.data come from in Django REST Framework?
- In DRF, how does field-level vs object-level validation work in serializers?
← PreviousNo login needed