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 trialXayaseth Boudsady
21,951 PointsNeed help with urlpatterns for Django 2.0 and greater
Can't seem to get the urlpattern to work, fo Django 2.0.
Following the example from the documentation, and it should work... https://docs.djangoproject.com/en/2.0/topics/http/urls/
from django.urls import path
from . import views
urlpatterns = [
path('', views.course_list),
path('<int:course_pk>/<int:step_pk>/', views.step_detail),
path('<int:pk>/', views.course_detail),
]
3 Answers
Henrik Christensen
Python Web Development Techdegree Student 38,322 PointsWhat problem(s) do you experience?
shaddowa
7,811 PointsI have the same problem, did you solve it?
Ian Salmon
Courses Plus Student 10,687 Pointsshaddowa This is what worked for me. The same as OP. I believe that his issue was with either the urlConf or views.py. Send me a message if you're still stuck!
path('', views.course_list),
path('<int:course_pk>/<int:step_pk>/', views.step_detail),
path('<int:pk>/', views.course_detail),
shaddowa
7,811 PointsI found that this worked, but only when i deleted the meta class in the step model. There was an issue with the ordering = ["order",] but i don't know why
Xayaseth Boudsady
21,951 PointsXayaseth Boudsady
21,951 PointsBasically the urlpattern is not correct. Can't use the same as the video tutorial as it is an old version of Django.
This is the error.
TemplateDoesNotExist at /courses/1/1/
http://127.0.0.1:8000/courses/1/1/
Henrik Christensen
Python Web Development Techdegree Student 38,322 PointsHenrik Christensen
Python Web Development Techdegree Student 38,322 PointsTemplateDoesNotExist are you sure that the template exist or you've added the right path to the template in your view?
Could you share your urlConf? (the urls.py in the main folder)