我正在用教程学习django1.8.3,我来到这里:Removing hardcoded URLs in templates。我遵循这一节,修改了polls/template/polls/index.html
,如下所示:
{% if latest_question_list %}
<ul>
{% for question in latest_question_list %}
<!--<li><a href="/polls/{{ question.id }}/">{{question.question_text}}</a></li>-->
<li><a href="{% url 'detail' question.id %}">{{ question.question_text }}</a></li>
{% endfor %}
</ul>
{% else %}
<p> No polls are available. </p>
{% endif %}
但是当我通过点击URL来访问这个问题时,我得到了404,就像这样:404 page when click a question。 我不知道我的代码怎么了?你知道吗
Django模板标记以
% }
(在链接到的错误页上)结尾,因此Django无法识别它。你知道吗删除空间。你知道吗
相关问题 更多 >
编程相关推荐