尊重所有人: 我想使用Django模板的可重用性功能
正如我在 base.html
中写的那样<title>{% block title %}{% trans 'Main Page title' %}{% endblock %}</title>
我的 otherfile.html 就是这个
{% block title %}Other file Title{% endblock %}
我想在不使用其他文件中的标签的情况下设置标题吗?
答案 0 :(得分:0)
您的 otherfile.html 顶部会显示此模板标记{% extends "base.html" %}
之后,您可以在otherfile.html中使用% block title %}Other file Title{% endblock %}
https://docs.djangoproject.com/en/2.0/ref/templates/language/#templates