Opened 9 years ago

Closed 9 years ago

#16561 closed Bug (invalid)

incorrect url in template

Reported by: tim.proffitt@… Owned by: nobody
Component: Documentation Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


in part 3 you have us noobs write the index template:

{% if latest_poll_list %}

{% for poll in latest_poll_list %}

<li><a href="/polls/{{ }}/">{{ poll.question }}</a></li>

{% endfor %}


then we go and decouple URLconfs which includes this line:

urlpatterns = patterns('polls.views',


and then (and I didn't notice this until the end) when we go to mysite/polls/ and see the list of polls generated from the template and view the source the links look like so:

<a href="polls/1/"> ... </a>

the polls prefix is redundant with the changes we made to urlconfs. when you click on one of the links you will be redirected to a 404 referencing the failure to find polls/polls/n.
this issue remains even later when we use the generic templates and completely rewrite urlconfs.

Change History (1)

comment:1 Changed 9 years ago by Chris Beaven

Resolution: invalid
Status: newclosed

Decoupling the app's URL configuration shouldn't change anything here.

Looks like you didn't follow the instructions exactly, because you should have <a href="/polls/1/">... (note the leading slash).

Here's something to look at after you've finished the tutorial, see if you can avoid hard-coding the /polls/ prefix in the template at all (Hint: url template tag or get_absolute_url+permalink decorator in the model)

Note: See TracTickets for help on using tickets.
Back to Top