Форум сайта python.su
Что-то непонятно поведение тега block при использовании его внутри шаблона, подключаемого через include:
#base.html
<html>
<head><title>{% block title %}Title{% endblock %}</title>
</head>
<body>
{% block body_content %}
{% include "2col.html" %}
{% endblock body_content %}
</body>
</html>
#2col.html
<div id="container">{% block content %}test content{% endblock %}</div>
<div id="sidebar">{% block sidebar %}test sidebar{% endblock %}</div>
#index.html
{% extends "base.html" %}
{% block content %} SUXX {% endblock content %}
{% block sidebar %} SUXX TO{% endblock sidebar %}
<html>
<head>
<title>Title</title>
</head>
<body>
<div id="container">test content</div>
<div id="sidebar">test sidebar</div>
</body>
</html>
Офлайн
https://docs.djangoproject.com/en/dev/topics/templates/#template-inheritance
Finally, note that you can't define multiple block tags with the same name in the same template. This limitation exists because a block tag works in “both” directions. That is, a block tag doesn't just provide a hole to fill – it also defines the content that fills the hole in the parent. If there were two similarly-named block tags in a template, that template's parent wouldn't know which one of the blocks' content to use.
Офлайн
Спасибо за ответ.
Офлайн