django中模板head标签中的内容进入body的奇怪问题解决方法

base.html

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>SecureKids {% block title %}{{title}}{% endblock %}</title> </head> <body> <div id="page-wrapper"> <div class="row"> <div class="col-lg-12"> <h1 class="page-header">{% block apartado %} {% endblock %}</h1> </div> <!-- /.col-lg-12 --> </div> <!-- /.row --> <p class="text-success">{% block msg %}{% endblock %}</p> <div class="row"> {% block contenido %}---{% endblock %} </div><!-- /.row --> </div><!-- /#page-wrapper --> </body> </html>

extends from base.html

{% extends "base.html" %} {%load i18n%} {% block apartado %} {% trans 'Control Panel' %} <small>{% trans 'Device' %} {{device.name}}</small> {% endblock %} {% block contenido %} <h2>{% trans 'WELLCOME' %}</h2> <div> <h3>{% trans 'Child:' %} <small>{{device.child.name}}</small></h3> <h3>{% trans 'Father's device:' %} <small>{{device.name}}</small></h3> </div> {% endblock %}

渲染后的内容

<html lang="en">
<head>
</head>
<body>
"


"
<meta charset="utf-8">
<title>SecureKids </title>


    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">
                    Control Panel <small>Device</small>
                </h1>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
             <p class="text-success"></p>               
            <div class="row">

                 <h2>WELLCOME</h2>
                 <div>
                   <h3>Child: <small>m</small></h3>
                   <h3>Father's device: <small>m disp</small></h3>

                </div>      
       </div><!-- /.row -->     
   </div><!-- /#page-wrapper -->
</body>
</html>

对这个问题百思不得其解,最后查到了,文件的编码问题,把文件编码改为Utf8 without BOM 就行了。

你可能感兴趣的:(django,模板)