Django Web Framework - Module quiz: Django REST framework

Django Web Framework - Module quiz: Django REST framework

  1. How do you accept a GET, POST and PUT call to a function-based view using an API decorator?

    • An API endpoint cannot accept multiple HTTP methods

    • api_view(['GET','POST','PUT'])

    • @api_view('GET','POST','PUT')

    • @api_view(['GET','POST','PUT'])

  2. What are the benefits of using a serializer? Choose all that apply.

    • It can save data to a database

    • It can validate data

    • It helps to authenticate API calls

    • It can automatically convert data to JSON or XML

    • It can convert user input and map it to models

    • It can convert model instances to native Python data types

  3. Which of the following are valid serializer classes in DRF? Choose all that apply.

    • RelationshipSerializer

    • Serializer

    • PrimaryKeySerializer

    • ModelSerializer

    • HyperLinkModelSerializer

  4. You can access the data attribute of a serializer class at any time.

    • True

    • False

  5. Which of the following renderers comes with DRF by default? Choose all that apply.

    • XML Renderer

    • YAML Renderer

    • JSON Renderer

    • HTML Renderer

  6. Which of the following statement is true about DRF?

    • Learning DRF is tough

    • DRF is a standalone framework

    • DRF is built for API development

    • DRF doesn’t work with different database engines

  7. Which of the following panels are available in the DDT or Django debug toolbar? Choose all that apply.

    • SQL

    • Throttle

    • Profiling

    • Headers

    • Network

  8. To serialize a queryset that returns more than one item, which of the following arguments is necessary for the serializer class?

    • many=True

    • multiple_items=True

    • related=True

  9. Which of the following statements are true about using renderers? Choose all that apply.

    • Renderers need an Accept header to work properly

    • You cannot use multiple renderers in a project

    • If no Accept header is present, DRF uses JSON renderer by default.

    • You cannot forcefully use a single renderer

    • Renderers can automatically convert the output

  10. How do you display related model fields as hyperlinks? Choose all that apply.

    • Using HyperlinkedModelSerializer

    • Using HyperlinkedRelatedField

    • A ModelSerializer can do it automatically

    • Using RelationshipSerializer