Tsallaka zuwa abun ciki
Justice Tech School

Template Inheritance

A base template defines blocks. Child templates extend it and fill the blocks, so layout is written once.

Example
<!-- base.html -->
<html><body>
  <nav>My Site</nav>
  {% block content %}{% endblock %}
</body></html>

<!-- index.html -->
{% extends "base.html" %}
{% block content %}<h1>Home</h1>{% endblock %}

Exercise

Use a parent.

{%  "base.html" %}

Quiz Test

Where must extends appear?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.