欢迎访问 如意编程网!

如意编程网

当前位置: 首页 > 前端技术 > HTML >内容正文

HTML

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

发布时间:2022/11/16 HTML 33 老码农
如意编程网 收集整理的这篇文章主要介绍了 must be the first tag in the template.">Django踩坑之ExtendsNode: extends 'base/base.html'> must be the first tag in the template. 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

模板继承报错:
extends 'base/base.html'> must be the first tag in the template
Django踩坑之ExtendsNode: 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.

总结

以上是如意编程网为你收集整理的must be the first tag in the template.">Django踩坑之ExtendsNode: extends 'base/base.html'> must be the first tag in the template.的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得如意编程网网站内容还不错,欢迎将如意编程网推荐给好友。