I have an app called exercise_tracker
and want to extend my base.html
with two templates: exercise_list.html
and footer.html
. For exercise_list.html
I have set a view
for footer.html
not.
It doesn't render the content of footer.html
. Can you give me a hint what I'm doing wrong?
views.py
from django.shortcuts import render
from django.utils import timezone
from .models import Exercise
def exercise_list(request):
exercises = Exercise.objects.filter(published_date__lte=timezone.now()).order_by('published_date')
return render(request, 'exercise_tracker/exercise_list.html', {"exercises": exercises})
base.html
<html>
<body>
{% block content %}
{% endblock %}
{% block footer %}
<p>Footer placeholder</p>
{% endblock %}
</body>
</html>
exercise_list.html
{% extends 'exercise_tracker/base.html' %}
{% block content %}
<table>
{% for exercise in exercises %}
<tr>
<td>{{ exercise.date_learned }}</td>
<td>{{ exercise.time_studied }}</td>
<td>{{ exercise.language_learned }}</td>
<td>{{ exercise.description|linebreaksbr }}</td>
</tr>
{% endfor %}
</table>
{% endblock %}
footer.html
{% extends 'exercise_tracker/base.html' %}
{% block footer %}
<p>Footer</p>
{% endblock %}