【发布时间】:2021-05-28 17:48:56
【问题描述】:
当网页在测试服务器上运行时,会显示我的 Django 模板语言标签。有谁知道为什么会发生这种情况? (网页上的其他所有内容都正常显示,标签甚至都在发挥作用。我只是不知道为什么会有文字。
页面的html:
<% extends "base.html" %>
<% block page_title %> Challenges <% endblock %>
<% block content %>
<ul>
{% for month in months%}
<li> <a href="{% url 'month-challenge' month %}">{{month|title}} </a></li>
{% endfor %}
</ul>
<% endblock %>
The template that the page is inheriting from:
<!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 page_title %} {% endblock %}</title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
我在这里查看过类似的帖子,但这些修复似乎都不适用于此处(直接打开 html 文档,在 { 和 % 之间留一个空格等。
【问题讨论】:
-
非常仔细地查看你的html。您至少有 4 行包含
<%和%>而不是{%和%}。这些是显示在您的浏览器中的行。 -
哦,哇,非常感谢你,你合法地为我节省了大约 3 年的时间,让我注意到这一点!