我有一个base.html文件,我可以在其中扩展其他页面。我在base.html中有这个代码:
base.html文件
<html lang="es-es">
<head>
<title>
Home - {% block titulo %}{% endblock %}
</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/static/style/main.css" rel="stylesheet" />
</head>
从base.html扩展的所有模板都有一些西班牙语单词和符号,我必须再次放置这个元标记(因此它不会给我带来unicode错误),即使在base.html文件中也是如此: / p>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
模板是否应该继承父模板中的所有标签?我做错了什么?
- 编辑2016年3月16日 -
这是一个孩子的例子。对于我在url文件中使用的ListView.as_view
视图,但并非所有从基础扩展的文件都使用相同的方法,尽管我必须在所有文件中插入元标记以用于重音和其他符号上班。
{% extends "base.html" %}
{% load static %}
<!--The next 2 lines after this comment
are in every html files that extends from the base file
-->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% block titulo %}
Lideres
{% endblock%}
{% block content %}
<h2>Listado de Teléfonos</h2>
{% endblock %}