must be the first tag in the template.">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.
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
模板继承报错:
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>
刷新:
总结
以上是如意编程网为你收集整理的must be the first tag in the template.">Django踩坑之ExtendsNode: extends 'base/base.html'> must be the first tag in the template.的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: HTML5常见的取值与单位
- 下一篇: C#解析HTML利器-Html Agil