I am able to render the home.html
and it prints Mary had a little lamb
which is sitetitle
Here is the code for home.html
<head>
</head>
<body>
<h1>{{sitetitle}}</h1>
<h1>{% block fun %} {% endblock %}</h1>
</body>
But it is not rendering the fun
block in title.html
, although it is in the same directory.
Here is the code for title.html
{% extends "home.html" %}
{% block fun %}
{{ link }}
{% endblock %}
Here is the code for views.py
from django.shortcuts import render
from models import siteprop
from django.template import loader
def testf(request) :
obj=siteprop.objects.first()
context=obj.__dict__
if '_state' in context:
del context['_state']
print context
return render(request,"home.html",context)
Here is the code for urls.py
from django.conf.urls import include, url
from django.contrib import admin
from thingslab import views
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^test/',views.testf,),
]
The
fun
block intitle.html
is not rendering because in your view you're renderinghome.html
.Django does not automatically know that the code of
title.html
should be included inhome.html
just because it also contains afun
block.You have to render
title.html
instead ofhome.html
: