tomisacat
tomisacat

Reputation: 526

django 1.8.3 tutorial index.html template wrong to get corrent url

I'm learning Django 1.8.3 with tutorial and I came here: Removing hardcoded URLs in templates. I followed this section and modified the polls/template/polls/index.html like this:

{% 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 %}

But when I access Question by clicking the URL I get 404 like this: 404 page when click a question. I don't know what's wrong with my code?

Upvotes: 0

Views: 106

Answers (1)

RemcoGerlich
RemcoGerlich

Reputation: 31270

Your Django template tag ends with % } (on the error page that you link to), and therefore Django doesn't recognize it.

Remove the space.

Upvotes: 2

Related Questions