上QQ阅读APP看书,第一时间看更新
Test your knowledge
- Under the hoods, the
@api_view
decorator is:- A wrapper that converts a function-based view into a subclass of the
rest_framework.views.APIView
class. - A wrapper that converts a function-based view into a serializer.
- A wrapper that converts a function-based view into a subclass of the
rest_framework.views.api_view
class.
- A wrapper that converts a function-based view into a subclass of the
- The browsable API, a feature included in Django REST Framework that:
- Generates human-friendly JSON output for each resource whenever the request specifies
application/json
as the value for theContent-type
key in the request header. - Generates human-friendly HTML output for each resource whenever the request specifies
text/html
as the value for theContent-type
key in the request header. - Generates human-friendly HTML output for each resource whenever the request specifies
application/json
as the value for theContent-type
key in the request header.
- Generates human-friendly JSON output for each resource whenever the request specifies
- The
rest_framework.serializers.ModelSerializer
class:- Automatically populates both a set of default constraints and a set of default parsers.
- populates both a set of default fields but doesn't automatically populate a set of default validators.
Automatically populates both a set of default fields but doesn't automatically populate a set of default validators. Automatically populates both a set of default fields and a set of default validators.
- The
rest_framework.serializers.ModelSerializer
class:- Provides default implementations for the
get
andpatch
methods. - Provides default implementations for the
get
andput
methods. - Provides default implementations for the
create
andupdate
methods.
- Provides default implementations for the
- The
Serializer
andModelSerializer
classes in Django REST Framework are similar to the following two classes in Django Web Framework:-
Form
andModelForm
classes. -
View
andModelView
classes. -
Controller
andModelController
classes.
-