Master Template - Django Templates - 07

Video thumbnail

Content Index

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