I have a project with the following urls.py
.
urlpatterns = [
path('category*/', include('student.urls')) // * could be replaced by a number
]
In that project I then have an application student whose urls.py
looks like this:
urlpatterns = [
path('all/', views.all, name='all')
]
So lets say when I type in the URL category1/all/
I get the list of all Category 1 students, but when I do category2/all/
I should be able to get the list of all Category 2 students. So by the time I reach all/
I have lost for which category I want to retrieve the list of all students. How can I still know in my students application which category students data should be retrieved?
You can work with a parameter:
urlpatterns = [ path('category<int:cat>/', include('student.urls')), ]
then the view all
takes that parameter:
def all(request, cat): # … pass
where cat
is thus an int
depending on the number in the path.