Расширения и блоки не работают в шаблонах Django
Я учусь использовать шаблоны Django, но не могу заставить extends и block работать.
Вот мой код.
template.html
<!DOCTYPE html>
<html>
<body>
{% block theTitle %}
{% endblock %}
</body>
</html>
textComponent.html
{% extends 'templates/template.html' %} {% block theTitle %}
<div>what is going on?</div>
{% endblock %}
Вот как организованы файлы:
_templates
__template.html
__textComponent.html
Следуя наследованию шаблонов, как насчет просто:
{% extends "template.html" %}
{% block theTitle %}
<div>what is going on?</div>
{% endblock %}
Согласно документации по тегу extends:
Normally the template name is relative to the template loader’s root directory.
Итак, вы, вероятно, ищете свой файл template.html внутри:
templates/templates/template.html
Это неверный путь.