我能够渲染它home.html
并打印出来Mary had a little lamb
sitetitle
这是代码home.html
<head>
</head>
<body>
<h1>{{sitetitle}}</h1>
<h1>{% block fun %} {% endblock %}</h1>
</body>
但它不会在 中渲染fun
块title.html
,尽管它位于同一目录中。
这是代码title.html
{% extends "home.html" %}
{% block fun %}
{{ link }}
{% endblock %}
这是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)
这是代码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,),
]