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 trialAhmad Lala
2,312 PointsHelp: NoReverseMatch at /courses/ Reverse for 'detail' with arguments '()' and keyword arguments '{'pk': 1}' not found.
Can someone please help:
I'm getting this error: NoReverseMatch at /courses/ Reverse for 'detail' with arguments '()' and keyword arguments '{'pk': 1}' not found. 0 pattern(s) tried: []
When trying to load the course_list.html <h2><a href="{% url 'detail' pk=course.pk %}">{{ course.title }}</a></h2>
My urls.py page: urlpatterns = [ url(r'^$', views.course_list, name='list'), url(r'(?P<course_pk>\d+)/(?P<step_pk>\d+)/$', views.step_detail, name='step'), url(r'(?P<pk>\d+)/$', views.course_detail, name='detail'), ]
Jeff Muday
Treehouse Moderator 28,720 PointsYour urlpatterns are fine.
To me, it looks like your template has an error in the parameter.
reference the Django tutorial. Look at the last heading "Namespacing URL names':
https://docs.djangoproject.com/en/1.10/intro/tutorial03/
If your context and namespace are correct and you are iterating through the courses, then this would work below:
<h2><a href="{% url 'detail' course.id %}">{{ course.title }}</a></h2>
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsChris Howell
Python Web Development Techdegree Graduate 49,702 PointsMake sure when you are trying to post code, you use the Markdown Cheatsheet for formatting to make it easier to read.
You will need to either paste in your courses urls.py and the learning_site urls.py code
or
If you are running this in a Workspace, you can share your Workspace and I can have a look at whats happening.