Django’s include() keeps an application’s URL patterns in its own module, then mounts them under a shared path prefix in the project routes. section 4.6.1
The request path /bands/musician/1/ first matches bands/ in the project URL file, then continues through bands.urls to the musician route and view. section 4.6.1
Mounting the bands routes
from django.urls import path, include urlpatterns = [ path("bands/", include("bands.urls")), ] The app-specific file can then define path("musician/<int:musician_id>/", views.musician, name="musician"). New bands routes stay in bands/urls.py instead of enlarging the project URL file. section 4.6.1
Listing 4.6 Registering all the URL routes in the bands app
# RiffMates/RiffMates/urls.py
...
from django.urls import path, include #1
...
urlpatterns = [
...
path('bands/', include("bands.urls")), #2
]
Inspect the complete project-level registration that imports include and mounts bands.urls beneath bands/. section 4.6.1
