首页 > Web开发 > 详细

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

时间:2020-05-30 13:54:41      阅读:195      评论:0      收藏:0      [点我收藏+]

模板继承报错:
extends ‘base/base.html‘> must be the first tag in the template
技术分享图片

base.html如下:


<!-- {% load static %}
{{name}} <img src="{% static "images/test.jpg" %}" alt="test-jpg"> -->

{% extends "base.html" %}

{% block mainbody %}
<p> 继承 base.html 文件</p>
{% endblock %}

最后发现,{%block mainbody %}必须放在base.html的第一行才可以,就算前面有注释也不行。
更改:

{% extends "base.html" %}

{% block mainbody %}
<p> 继承 base.html 文件</p>
{% endblock %}

<!-- <!DOCTYPE html>
<html lang="en">
<head>

刷新:
技术分享图片

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

原文:https://www.cnblogs.com/johnyang/p/12992085.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!