Master Template - Django Templates - 07

We are going to create the master template, once the detail and list views have been created in Django, so it would be something like this, which I show you here:

We create the master template:

mystore\elements\templates\base.html

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Django</title>
</head>
<body>
   {% block content %}
     
   {% endblock  %}

   {% block footer %}
       <footer>
           <p>2025 - All rights reserved</p>
       </footer>
   {% endblock  %}
</body>
</html>

Now, we use the template in the views created above:

List

We create the view and its template for the listing:

mystore\elements\views.py

{% extends "base.html" %}

{% block content %}
   Index
{% endblock %}

Detail

We create the view and its template for the detail of the products of type:

mystore\elements\views.py

{% extends "base.html" %}

{% block content %}
   Detail
{% endblock %}

I agree to receive announcements of interest about this Blog.

Let's create the master template for our application in Django

- Andrés Cruz

En español

This material is part of my complete course and book; You can purchase them from the books and/or courses section, Curso y Libro desarrollo web con Django 5 y Python 3 + integración con Vue 3, Bootstrap y Alpine.js.

)