Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialeodell
26,386 PointsPage not found when trying to link back from 'step' to 'detail'
At 8:00 in the video, Kenneth adds an anchor tag to the h2 element in the step_detail.html file. The anchor tag is supposed to link back to course_detail.html. I think my syntax is correct but I receive an error when clicking on the course title/anchor tag that should send me back to the course detail page. What am I doing wrong here?
The error i receive is:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/courses/1/2/%25%20url%20'detail'%20pk%3Dstep.course.pk%20%25
Using the URLconf defined in learning_site.urls, Django tried these URL patterns, in this order:
^courses/ (?P<course_pk>\d+)/(?P<step_pk>\d+)/$ [name='step']
^courses/ (?P<pk>\d+)/$ [name='detail']
^courses/ ^$ [name='lsit']
^admin/
^$
^static\/(?P<path>.*)$
The current URL, courses/1/2/% url 'detail' pk=step.course.pk %, didn't match any of these.
and my code for that page (sorry I can't provide a snapshot as I'm doing this on my local machine) is:
{% extends 'layout.html' %}
{% block title %}{{ step.course.title}} | {{ step.title }}{% endblock title %}
{% block content %}
<article>
<h2><a href="% url 'detail' pk=step.course.pk %">{{ step.course.title }}</a></h2>
<h3>{{ step.title }}</h3>
{{ step.content | linebreaks }}
</article>
{% endblock content %}
I'm using django 1.8.1, as shown in the video and am on Windows 10 if that's relevant.
1 Answer
Todd Anderson
4,260 PointsHi!
You are missing your curly braces in the <a> link before the % and after the closing %.
<a href="{% url 'detail' pk=step.course.pk %}">