Bird
0
0

Given this DRF generic view code, what will be the HTTP method supported and the main action performed?

medium📝 component behavior Q13 of 15
Django - REST Framework Basics
Given this DRF generic view code, what will be the HTTP method supported and the main action performed?
class ArticleDetail(generics.RetrieveUpdateDestroyAPIView):
    queryset = Article.objects.all()
    serializer_class = ArticleSerializer
ASupports only POST method to create a new article
BSupports GET, PUT, PATCH, DELETE methods to retrieve, update, or delete an article
CSupports GET method to list all articles
DSupports DELETE method only to remove all articles
Step-by-Step Solution
Solution:
  1. Step 1: Understand RetrieveUpdateDestroyAPIView

    This generic view supports retrieving a single object (GET), updating it (PUT/PATCH), and deleting it (DELETE).
  2. Step 2: Match HTTP methods to actions

    Supports GET, PUT, PATCH, DELETE methods to retrieve, update, or delete an article correctly describes the supported methods (GET for retrieve, PUT/PATCH for update, DELETE for destroy) for a single article. Options A, C, and D describe incorrect methods or actions.
  3. Final Answer:

    Supports GET, PUT, PATCH, DELETE methods to retrieve, update, or delete an article -> Option B
  4. Quick Check:

    RetrieveUpdateDestroyAPIView = GET, PUT/PATCH, DELETE [OK]
Quick Trick: RetrieveUpdateDestroyAPIView handles GET, PUT/PATCH, DELETE [OK]
Common Mistakes:
MISTAKES
  • Thinking it supports POST for creation
  • Confusing list view with detail view
  • Assuming it deletes all objects instead of one

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes