英文:
Getting A Django Template Syntax Error. How do I solve this?
问题
我尝试在index.html中扩展base.html文件。 但是我一直收到以下错误消息:
在第2行上的无效块标签:'endblock'。 您是否忘记注册或加载此标签?
base.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{% block title %}{% endblock %}</title>
<!-- {% block css_files %} {% endblock %} -->
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
index.html
{% extends 'base.html' %} {% block title %} My Blog {% endblock %} {% block
content %} Hello {% endblock %}
我确保了大括号和百分号之间没有任何间隔。 问题可能出在哪里?
英文:
I tried to extend the base.html file in index.html. But I keep getting the following error:
Invalid block tag on line 2: 'endblock'. Did you forget to register or load this tag?
base.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{% block title %}{% endblock %}</title>
<!-- {% block css_files %} {% endblock %} -->
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
index.html
{% extends 'base.html' %} {% block title %} My Blog {% endblock %} {% block
content %} Hello {% endblock %}
I've made sure there are no gaps between any of the curly braces and %. Where could be the issue?
答案1
得分: 1
{% extends 'base.html' %}
{% block title %}我的博客{% endblock %}
{% block content %}你好{% endblock %}
英文:
You can't have a newline in the middle of a tag, start each block tag on a separate line
{% extends 'base.html' %}
{% block title %}My Blog{% endblock %}
{% block content %}Hello{% endblock %}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论