0

テンプレートディレクトリからページを返すビューがありますが、問題ありません。

def home(request):
    c = {}
    return render_to_response('home.html', c, context_instance=RequestContext(request))

home.htmlがextendsのない単純な Web ページの場合、問題なく返されます。

ただし、{% extends "base.html" %} などのインクルードを使用すると、子の home.html のコンテンツを追加せずに単に base.html を返します。何が原因でしょうか?

home.html

{% extends "base.html" %}
{% block title %}Home{% endblock %}
{% block content %}
This is the homepage.
{% endblock %} 

base.html

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>{% block content %}{% endblock %}</title>
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>

現時点では、これは base.html のコピーを次のように返しています。

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
</head>

<body>

</body>

</html>

コンテンツまたはタイトル ブロックが含まれていないのはなぜですか?

4

1 に答える 1