Django Web Framework - Module Quiz: Views

Django Web Framework - Module Quiz: Views

  1. To add a URL pattern with regex, you use the re_path() function instead of the path() function.

    • True

    • False

  2. Which of the following sentences about the path() function is correct? Select all that apply.

    • The path() function is defined in the django.urls module.

    • The URL string parameter of the path() function captures query parameters from the URL.

    • The path() function is used to define a URL pattern.

    • The path() function returns the path of the Django app.

  3. Complete the sentence. The path converters capture _____ from the URL.

    • Query parameters

    • URL parameters

    • Body parameters.

    • Path parameters

  4. The request.user attribute contains the information of the current user.

    • True

    • False

  5. Complete the following sentence. The HTTP status code starting with 5 implies that:

    • The request has been received and is under process.

    • There is a client-side error.

    • The action has been successfully completed.

    • The server has encountered an error.

  6. What are the important features of a class-based view? Select all that apply.

    • Class-based views are reusable.

    • A class-based view subclasses the django.view.View base class.

    • The as_view() method maps a URL to a class-based view.

    • A class-based view implements different methods for each HTTP method.

  7. The Http404 response is a convenient alternative for an HttpResponse.

    • True

    • False

  8. Complete the following sentence. The URL name is _______________.

    Select all that apply.

    • used by the reverse() function to fetch the URL mapped with the view function.

    • an optional parameter passed inside the path() function.

    • used to define URL namespace.

    • passed as the name parameter in the path() function.

  9. Can you define views in the views.py file in the projects folder?

    • Yes

    • No

  10. Complete the following sentence. To override the default error view, _______________.

    Select all that apply.

    • specify the appropriate handler in the project's URLConf.

    • define the custom view in the project folder.

    • you should define the custom error handler view in the app's views.py file.

    • there's no need to override the default error views.