I can't expand the base.html template with the base.html template

Content base.html

 <div id="main-container"> <!-- HEADER --> {% block header %}{% endblock %} <!-- END HEADER --> </div> 

Contents header.html

 {% extends "blog/base.html" %} {% block header %} <header id="header"> *** </header> {% endblock %} 

At the output I get the code:

 <div id="main-container"> <!-- HEADER --> <!-- END HEADER --> 

Why not get to expand the template? Through {% include "blog/header.html" %} - works, but not with extends . I use Django 1.10.1

views.py

 from django.shortcuts import render from django.utils import timezone from .models import Post from django.shortcuts import render, get_object_or_404 def post_list(request): posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date') return render(request, 'blog/index.html', {'posts': posts}) def post_detail(request, pk): post = get_object_or_404 (Post, pk=pk) return render(request, 'blog/base.html', {'post': post}) def header(request): return render (request, 'blog/header.html') 
  • one
    Show the view code, maybe you specify the wrong template. And correct the brackets in {% extends "blog/base.html %} , but it is not clear if you have a typo in copy-paste or code. - Flowneee
  • Everything is written correctly. - Mr Fix
  • Added code views.py - Dev KD
  • Actually you only have the last view ( def header(request) ) and the def header(request) should be displayed, in the rest it should not be. Specify which of the specified views in your works not so. - Flowneee
  • Now added def header(request) in views.py, but the block is still not displayed. - Dev KD

0