我仔细查看了我的代码几次以及此错误的所有先前答案,但仍无法找到解决方案。
以下是有问题的代码:
base.html:
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-COMPATIBLE" content="IE=edge">
<meta name="viewport" content="wideth=device-width, initial-scale=1">
<title>{% block title %}Rapid Prototypes {% endblock %}</title>
<link rel="stylesheet" href="{% static 'css/site.css' %}">
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
</head>
<body id="{% block body-id %}body{% endblock %}">
{% block top-nav-wrapper %}
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle"
data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Rapid Prototypes</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li {% if slug=='index' %}class="active"{% endif %}>
<a href="/">Home</a>
</li>
<li {% if slug=='contact' %}class="active"{% endif %}>
<a href="{% url 'page' 'contact' %}">Contact</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li {% if slug=='login' %}class="active"{% endif %}>
<a href="{% url 'page' 'login' %}">Login</a>
</li>
</ul>
</div>
</div>
</div>
{% endblock %}
{% block content %}{% endblock %}
<script src="{% static 'js/jquery.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
</body>
</html>
该错误据说是在第29行,即第一个if语句的行。确切的错误陈述是:无法解析余数:&#39; ==&#39; index&#39;&#39;来自&#39; slug ==&#39; index&#39;&#39;
提前感谢您的帮助!