Listing individual movies
To list individual movies, we will follow these steps: (i) configuring individual movies URLs, (ii) defining the views
show
function, (iii) creating a movies show
template, and (iv) adding individual movie links on the movies page.
Configuring individual movies URLs
In /movies/urls.py
, add the next path in bold:
from django.urls import path from . import views urlpatterns = [ path('', views.index, name='movies.index'), path('<int:id>/', views.show, name='movies.show'), ]
This path is a little different from the previously defined paths. The <int:id>
part indicates that this path expects an integer value to be passed from the URL and that the integer value will be associated with a variable named id
, which will be used to identify which movie data to show. For example, if we access movies/1
, the application will display the data of the movie with id...