← Backend PythonQuestion 3 of 49
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?
- When do you use selectrelated() vs prefetchrelated() in Django?
- Examples of Python stdlib modules runnable as scripts (python -m ...):
- What are the first steps to debug performance issues in Django?
← PreviousNo login needed