Bird
0
0

Given this APIView code, what will be the HTTP status code in the response?

medium📝 component behavior Q13 of 15
Django - REST Framework Basics
Given this APIView code, what will be the HTTP status code in the response?
from rest_framework.views import APIView
from rest_framework.response import Response

class HelloView(APIView):
    def get(self, request):
        return Response({"message": "Hello!"}, status=201)
A201 Created
B404 Not Found
C200 OK
D500 Internal Server Error
Step-by-Step Solution
Solution:
  1. Step 1: Identify the status code in Response

    The Response is returned with status=201, which means Created.
  2. Step 2: Match status code to HTTP meaning

    201 means resource created successfully, so the response status will be 201 Created.
  3. Final Answer:

    201 Created -> Option A
  4. Quick Check:

    Status=201 means Created [OK]
Quick Trick: Check status argument in Response call [OK]
Common Mistakes:
MISTAKES
  • Assuming default 200 OK without checking status
  • Confusing 201 with 404 or 500
  • Ignoring the status parameter in Response

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes