关闭

Django:ExtendsNode: extends 'base/base.html'> must be the first tag in the template.

标签: djangopython
1258人阅读 评论(0) 收藏 举报
分类:

学习Django的过程,敲教程的样例过程,到模板继承这里,总是报下面的错误
error

子模板继承的代码如下


<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
    <title>The Future time</title>
</head>
<body>
{# {% include "include/nav.html" %} #}
<h1>My helpful timestamp site</h1>
<p>it is will be {{next_time}} after {{hour_offset}}</p>

<hr>
<p>Thanks for visiting my site.</p> 

</body> 
</html>  -->
{%extends 'base/base.html'%}

{%block title%} Future Time{%endblock%}
{%block content%}
<p> it is will be {{next_time}} after {{hour_offset}}</p>
{%endblock%}

纠结了好长时间,然后根据错误信息,把未注释的代码放到开头,再试试,结果 ok了, 不知道Django 这样设计的目的。。醉了
如下子类继承

{%extends 'base/base.html'%}

{%block title%} Future Time{%endblock%}
{%block content%}
<p> it is will be {{next_time}} after {{hour_offset}}</p>
{%endblock%}
<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
    <title>The Future time</title>
</head>
<body>
{# {% include "include/nav.html" %} #}
<h1>My helpful timestamp site</h1>
<p>it is will be {{next_time}} after {{hour_offset}}</p>

<hr>
<p>Thanks for visiting my site.</p> 

</body> 
</html>  -->

刷新页面:
这里写图片描述

1
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:185942次
    • 积分:2901
    • 等级:
    • 排名:第12291名
    • 原创:105篇
    • 转载:19篇
    • 译文:0篇
    • 评论:17条
    文章分类
    最新评论