Unit 3: Templates, Debugging and Testing - Subjective Questions

INT253 — Web Development In Python Using Django • Practice Questions with Detailed Answers

20 questions

1

Define a Django template. Explain its role in Django's Model-Template-View architecture.

2

Describe the steps required to create, configure, and render a template in a Django project.

3

Explain the main components of Django Template Language (DTL), with suitable examples.

4

Explain how Django template variables are resolved. What happens when a variable does not exist?

5

What are Django template tags? Describe any five commonly used template tags.

6

Describe the use of the for tag in Django templates. Explain loop variables and the {% empty %} clause.

7

Explain the syntax and working of if, elif, and else statements in Django templates. Mention the operators supported by DTL conditions.

8

What are template filters in Django? Explain how filters are applied and describe any five built-in filters.

9

Explain how dynamic templates are created in Django by passing context data from a view. Illustrate the complete request-to-response flow.

10

What is template inheritance in Django? Create a conceptual parent-child template structure and explain how it avoids duplication.

11

Distinguish between {% extends %}, {% block %}, and {% include %} in Django templates.

12

Explain the importance of automatic HTML escaping in Django templates. Compare the escape, safe, and autoescape features.

13

A view passes {'numbers': [2, 5, 8, 11]} to a template. Write and explain DTL logic that displays whether each number is even or odd and shows a message when the list is empty.

14

Explain how Django's debugging mode works. Why must DEBUG be disabled in a production environment?

15

Describe a systematic procedure for debugging common Django template errors.

16

Explain how logging can be used to debug a Django application. Compare logging with temporary print() statements.

17

Define testing in Django. Explain the structure and life cycle of a test case created using django.test.TestCase.

18

Describe how Django's test client can be used to test a view, its status code, template, context, and rendered content.

19

Distinguish between unit testing, integration testing, and functional testing in the context of a Django application.

20

Design a comprehensive testing strategy for a Django page that displays a dynamic student list using template inheritance, loops, and conditional statements.