Bird
0
0

Given this Django REST Framework view code, what will you see when you visit the URL in a browser?

medium📝 component behavior Q13 of 15
Django - REST Framework Basics
Given this Django REST Framework view code, what will you see when you visit the URL in a browser?
from rest_framework.views import APIView
from rest_framework.response import Response

class HelloView(APIView):
    def get(self, request):
        return Response({"message": "Hello, world!"})
AA JSON response with {"message": "Hello, world!"} and a browsable API interface
BA plain HTML page with no JSON data
CA 404 Not Found error
DA server error due to missing template
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the APIView behavior

    The view returns a JSON response with the message "Hello, world!" on GET requests.
  2. Step 2: Understand browsable API output

    Because Django REST Framework is used with APIView, the browsable API interface will show JSON data plus a web interface for testing.
  3. Final Answer:

    A JSON response with {"message": "Hello, world!"} and a browsable API interface -> Option A
  4. Quick Check:

    APIView + DRF = JSON + browsable API [OK]
Quick Trick: APIView returns JSON plus browsable API page [OK]
Common Mistakes:
MISTAKES
  • Expecting plain HTML instead of JSON
  • Assuming missing template causes error
  • Confusing 404 error with missing URL

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes