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 trialTeam GDiz
Courses Plus Student 24,942 PointsPage not found at courses/1
Hi guys am getting the following error for Add a detail view.
Page not found (404) Request Method: GET Request URL: http://localhost:8000/courses/1/ Using the URLconf defined in tester.urls, Django tried these URL patterns, in this order: ^courses/ ^$ ^courses/ ^$ ^admin/ ^$ ^static\/(?P<path>.*)$ The current URL, courses/1/, didn't match any of these.
Cannot see the detail page.
This is the regex i use for the url -
urlpatterns = [ url(r'^$', views.course_list), url(r'(?P<pk>\d+)/$', views.course_detail), ]
Any idea where I could be going wrong?
2 Answers
Iain Simmons
Treehouse Moderator 32,305 PointsMake sure in your learning_site/urls.py
you have the following, and then your code in courses/urls.py
would have the routes for the course detail page:
urlpatterns = [
url(r'^courses/', include('courses.urls', namespace='courses')),
url(r'^admin/', include(admin.site.urls))
]
Jude Molloy
7,470 PointsThanks this helped me :)
Jeremy Nootenboom
Python Web Development Techdegree Student 6,876 PointsI had this problem as well, your solution fixed it. Thanks!
Kenneth doesn't have this in the video though. Is the version of Django he's using in the video deprecated? This is confusing for those just learning the basics.
Khem Myrick
Python Web Development Techdegree Graduate 18,701 PointsThank you Iain, that helped me too! (I didn't have namespace='courses')
Dmitry Karamin
10,099 PointsDmitry Karamin
10,099 Pointstry
url(r'courses/(?P<pk>\d+)/$', views.course_detail)