Django Web Framework - Module Quiz: Templates

Django Web Framework - Module Quiz: Templates

  1. Which of the following sentences about templates are true? Select all that apply.

    • A template is a web page that has blocks of template language syntax inside the HTML script.

    • A template extracts the data from a model and generates a dynamic page.

    • A template helps to include conditional processing logic in a web page.

    • A template is the data layer of the application.

  2. The view function loads a template and fills the context data in it.

    • True

    • False

  3. Which of the following tags are used for implementing template inheritance? Select all that apply.

    • {% extends %}

    • {% include %}

    • {% block %}

    • {% endfor %}

  4. True or false. To implement template inheritance, the parent template must have the name base.html.

    • True

    • False

  5. In which module is the render() function defined?

    • django.urls

    • django.shortcuts

    • django.db

    • django.contrib

  6. Which of the following template filters returns a titlecase representation of a string?

    Hint: titlecase makes words start with an uppercase character and the remaining characters lowercase.

    • upper

    • lower

    • title

    • length

  7. Putting one loop inside another is called nesting of loops. Can you use nested loops in a template?

    • Yes

    • No

  8. Complete the sentence. The view function passes a ______ as the context data to a template.

    • Python list

    • Python string

    • Python dict

    • Python tuple

  9. What are the advantages of a class-based view? Select all that apply.

    • Code reusability

    • Extensible code

    • Class-based views are simple to implement

    • Implicit code flow

  10. Suppose that a Django app named myapp has the Employee model. Which of the following statements about the generic ListView class are correct? Select all that apply.

    • A generic ListView class must be named EmployeeList

    • A generic ListView class should set the model attribute to myapp_Employee

    • A generic ListView class lists all the rows in the Employee table

    • A generic ListView class needs a template named EmployeeList.html