Recall & Review
beginner
What is template inheritance in Django?
Template inheritance lets you create a base template with common layout and extend it in child templates to reuse code and keep pages consistent.
Click to reveal answer
beginner
How do you specify a base template to extend in a Django template?
Use the {% raw %}{% extends 'base.html' %}{% endraw %} tag at the top of your child template to inherit from 'base.html'.
Click to reveal answer
beginner
What is the purpose of {% raw %}{% block %}{% endblock %}{% endraw %} tags in Django templates?
Blocks define sections in the base template that child templates can override to insert their own content.
Click to reveal answer
intermediate
If a child template does not override a block, what happens?
The content inside the block in the base template is used as default and shown in the rendered page.
Click to reveal answer
beginner
Why is template inheritance useful in web development?
It saves time by avoiding repeated code, ensures consistent look across pages, and makes maintenance easier by changing the base template once.
Click to reveal answer
Which tag do you use to inherit from a base template in Django?
✗ Incorrect
The {% raw %}{% extends %}{% endraw %} tag is used to inherit from a base template.
What does the {% raw %}{% block %}{% endblock %}{% endraw %} tag do in a base template?
✗ Incorrect
Blocks mark sections in the base template that child templates can replace with their own content.
If a child template does not override a block, what content is shown?
✗ Incorrect
The base template's block content acts as default if the child does not override it.
Where should the {% raw %}{% extends %}{% endraw %} tag be placed in a Django template?
✗ Incorrect
The {% raw %}{% extends %}{% endraw %} tag must be the first tag in the template.
What is a key benefit of using template inheritance?
✗ Incorrect
Template inheritance helps reuse layout and avoid repeating the same HTML in many files.
Explain how template inheritance works in Django using a base template and child templates.
Think about how a master page sets the frame and others fill in details.
You got /4 concepts.
Describe why using a base template with blocks is better than copying the same HTML in every page.
Imagine changing a header on 100 pages vs just one file.
You got /4 concepts.