Django Web Framework - Final graded quiz: APIs

Django Web Framework - Final graded quiz: APIs

  1. To accept a GET, PUT, POST and DELETE call, which generic view do you need to extend in your class-based view?

    • RetrieveUpdateDestroyAPIView

    • CreateAPIView

    • RetrieveUpdateAPIView

    • ListCreateAPIView

  2. Which of the following decorator functions can be used to display the browsable API view from a function-based view?

    • No decorator is needed, DRF handles this automatically.

    • throttle_classes() decorator

    • api_view() decorator

    • permission_classes() decorator

  3. A model has two fields – id and title. When linked from the serializers, this model always shows the value of the id field. To display the value of the title field instead of the id field, you need to override the __________ method inside the model class.

    • str

    • id

    • repr

    • title

    • This is not possible

  4. PascaleCase is the ideal naming convention for writing API endpoint names.

    • True

    • False

  5. How can you keep project dependencies isolated from other projects and avoid conflicts?

    • Use a virtual environment

    • Use a Piplock file

    • Use a global environment

    • Use a requirements.txt file

  6. Which signing mechanism is used to sign an API call?

    • TOKEN

    • JWT

    • HMAC

    • SHA

  7. A watchlist is used to pause the code execution on a specific line and check the values of the current variables.

    • True

    • False

  8. Djoser automatically creates authentication and authorization API endpoints in the DRF based API projects.

    • True

    • False

  9. You are working on a project where the API client needs to send two fields with their values – email and confirmation_email. As an API developer, you need to check if the value for both these fields are the same before saving the email address in the database. How can you do that? Choose all that apply.

    • This can be done using the UniqueTogetherValidator class in the model

    • This can be done using the UniqueTogetherValidator class in the serializer

    • This can be done using the UniqueTogetherValidator class in the view file

    • This can be done using the UniqueValidator class in the serializer

    • This can be done in the serializer by using the validate() method

  10. What are the benefits of caching? Choose all that apply.

    • Less load on the database

    • Increased security

    • Save bandwidth and network resources

    • Less load on the web server

    • Reduced infrastructure bills