Python Django扩展UTF-8

Python Django扩展UTF-8,python,html,django,Python,Html,Django,我几天前才开始学习Django,有点奇怪。实际上,我使用Visual Studio 2017和Django的扩展。我使用VisualStudio模板创建了一个新项目。我的问题是,当我在其他页面上扩展UTF-8时,它只能在My layout.html上工作,下面是一些代码: Layout.html <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-wi

我几天前才开始学习Django,有点奇怪。实际上,我使用Visual Studio 2017和Django的扩展。我使用VisualStudio模板创建了一个新项目。我的问题是,当我在其他页面上扩展UTF-8时,它只能在My layout.html上工作,下面是一些代码:

Layout.html

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"  charset="utf-8">
    <title>{{ title }} - My Django Application</title> <!-- Titre de la page modifiable dans /template/app/views.py -->
    {% load staticfiles %}
    <link rel="stylesheet" type="text/css" href="{% static 'app/content/bootstrap.min.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'app/content/site.css' %}" />
    <script src="{% static 'app/scripts/modernizr-2.6.2.js' %}"></script>
</head>

<body>
    <!-- Barre de navigation -->
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header" id="red">
                <!-- Menu format mobile/petite page -->
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <!-- Titre du site -->
                <a href="/" class="navbar-brand">Site de test</a>
            </div>
            <!-- Barre de navigation : Selection des pages -->
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li><a href="{% url 'home' %}">Présentation</a></li>
                    <li><a href="{% url 'about' %}">A propos</a></li>
                    <li><a href="{% url 'contact' %}">Me contacter</a></li>
                </ul>
                {% include 'app/loginpartial.html' %}
            </div>
        </div>
    </div>

    <!-- Contenu de la page -->
    <div class="container body-content">
{% block content %}{% endblock %}
        <hr/>
        <footer>
            <p>&copy; {{ year }} - Site de test</p>
        </footer>
    </div>

    <script src="{% static 'app/scripts/jquery-1.10.2.js' %}"></script>
    <script src="{% static 'app/scripts/bootstrap.js' %}"></script>
    <script src="{% static 'app/scripts/respond.js' %}"></script>
{% block scripts %}{% endblock %}

</body>
</html>

{{title}}-我的Django应用程序
{%load staticfiles%}
{%include'app/loginpartial.html%} {%block content%}{%endblock%}
&抄袭;{{year}-现场测试

{%block scripts%}{%endblock%}
About.html(我在这里使用Layout.html):

<!-- On inclue le layout (navbar + footer) -->
{% extends "app/layout.html" %}

{% block content %}

<h2>{{ title }}.</h2> <!-- Titre de la page modifiable dans /template/app/views.py -->
<h3>{{ message }}</h3>

<p> é à è ù</p>

{% endblock %}

{%extends“app/layout.html”%}
{%block content%}
{{title}}。
{{message}}
èèù

{%endblock%}
下面是错误:

“utf-8”编解码器无法解码位置224处的字节0xe9:无效的连续字节 无法编码/解码的字符串为:� � �


我不知道为什么meta charset=“UTF-8”在About.html上不起作用,而Layout.html中有一个“é”。

您的Visual Studio可能没有将文件保存在UTF-8中,这可能会导致文件中断。虽然我不知道VisualStudio,但它可能会给你一个搜索的线索。是的,我想可能是这样。但是Layout.html文件正常加载时带有一个“é”不是有点奇怪吗?