Complete the code to enable the browsable API interface in Django REST Framework settings.
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': [
'rest_framework.renderers.JSONRenderer',
[1]
]
}To enable the browsable API interface, you add 'rest_framework.renderers.BrowsableAPIRenderer' to the DEFAULT_RENDERER_CLASSES list in your settings.
Complete the code to import the browsable API renderer in your Django REST Framework views.
from rest_framework.renderers import [1]
You import BrowsableAPIRenderer from rest_framework.renderers to use it in your views or settings.
Fix the error in the view to enable the browsable API renderer.
from rest_framework.views import APIView from rest_framework.response import Response from rest_framework.renderers import JSONRenderer, [1] class HelloView(APIView): renderer_classes = [JSONRenderer, BrowsableAPIRenderer] def get(self, request): return Response({'message': 'Hello, world!'})
The view must import BrowsableAPIRenderer to use it in renderer_classes. This enables the browsable API interface for this view.
Fill both blanks to set the default renderer classes including the browsable API in Django settings.
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': [
[1],
[2]
]
}The default renderer classes should include JSONRenderer for JSON output and BrowsableAPIRenderer for the browsable API interface.
Fill all three blanks to customize a view to support JSON and browsable API renderers with a simple GET response.
from rest_framework.views import APIView from rest_framework.response import Response from rest_framework.renderers import [1], [2] class CustomView(APIView): renderer_classes = [[3]] def get(self, request): return Response({'status': 'success'})
You import both JSONRenderer and BrowsableAPIRenderer and set renderer_classes to include both so the view supports JSON and browsable API output.