Reputation: 18
I´m working on a Django application but jinja doesn´t render the view. I need to separate those templates because I want to include specific content.
When I open data.html and data2.html I can see the values "1" respectively "4". But when I open test.html I don´t see the values. And multiple {% extends %} don´t work.
How can I load data.html and data2.html into test.html with the rendered data?
My views in Django:
def data1(request):
return render(request, 'user_backend/pages/data.html',{'a':1,
"b":2,
"c":3})
def data2(request):
return render(request, 'user_backend/pages/data2.html',{'d':4,
"e":5,
"f":6})
def test_temp(request):
return render(request,"user_backend/pages/test.html")
My templates:
test.html
{% load staticfiles %}
<h1>Data from data.html</h1>
{% include "user_backend/pages/data.html" %}
{% include "user_backend/pages/data2.html" %}
data.html
<p>Data = {{a}} </p>
data2.html
<p>Data2 = {{d}} </p>
Upvotes: 0
Views: 383
Reputation: 483
Include only includes your html files and it will not call the corresponding view and render it for you. You should pass the values of a
and d
to test.html and while including, it will render the value for you inplace of the variables.
Upvotes: 1