Variable Arguments From URLs: Routing and Views
In the previous lesson, you learned how to pull one specific resource out of your database. Now you need to build that code into your views and set up the correct routing so that you’ll be able to see the details page of one of your projects.
urlpatterns in your
projects app, you had an empty path that just went to
projects without anything afterwards and then rendered your
all_projects view. Now, you need to add a second path:
urlpatterns = [ path('', views.all_projects), path('<int:pk>', views.project_detail) ]
You can use the characters
> to captures a part of a URL and pass it forward into your app.
Comments & Discussion
Become a Member to join the conversation.