Reputation: 36277
I'm working with django 1.10 and python 3.6 in win 10.
In my main template (index.html) I have:
<div class="col-lg-5 col-sm-6">
<div class="clearfix"></div>
<h2 class="section-heading">We can help:</h2>
{% block 'body' %}
{% endblock %}
</div>
need3.html template:
{% extends 'index.html' %}
{% block 'body' %}
<p><big>Hello, ......
{% endblock %}
my code has:
def index(request):
form = MyForm()
return render(request, 'index.html', {'form': form, 'hero_phrase': 'Would you be interested in x?','body':'need3.html'})
However as you can see in the screenshot need3 template does not show up. What am I doing wrong?
Upvotes: 0
Views: 56
Reputation: 8077
From your index
function, you are rendering the index.html
template.
So, if you want your need3.html
template to show within your index
template, you just need to include it your main template:
<div class="col-lg-5 col-sm-6">
<div class="clearfix"></div>
<h2 class="section-heading">We can help:</h2>
{% include ´need3.html´ %}
</div>
The other way around would be to render the need3.html
template inside your index function:
def index(request):
form = MyForm()
return render(request, 'need3.html', {'form': form, 'hero_phrase': 'Would you be interested in x?','body':'need3.html'})
Upvotes: 1
Reputation: 47
my guess is this
{% block 'body' %}
you don't need to make body string, just use it like this
{% block body %}
Upvotes: 1