Django.3教程索引.html模板错误,无法获得正确的u

2024-04-25 13:49:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用教程学习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。 我不知道我的代码怎么了?你知道吗


Tags: textinid教程liulurlslatest