Challenge 2: Wire It Into the Project — Possible Solution ==================================================================== # mysite/urls.py — the project's root routing table from django.contrib import admin from django.urls import path, include urlpatterns = [ path("admin/", admin.site.urls), path("books/", include("catalog.urls")), path("accounts/", include("accounts.urls")), ] FINAL FULL PATHS FOR EACH ROUTE FROM CHALLENGE 1 -------------------------------------------------- Given catalog.urls is included under the "books/" prefix: - path("", views.book_list, name="book-list") -> combined with the "books/" prefix -> full path: /books/ - path("/", views.book_detail, name="book-detail") -> full path: /books// (e.g. /books/42/) - path("category//", views.by_category, name="book-category") -> full path: /books/category// (e.g. /books/category/sci-fi/) WHY THIS WORKS -------------- - include("catalog.urls") tells Django: "for anything under books/, hand the REST of the path off to catalog's own urlpatterns list, stripping the books/ prefix before matching against catalog's patterns." This is why catalog/urls.py itself never mentions "books/" anywhere — it's written as if it owned the root, and the project decides what prefix to mount it under. - Because the prefix is decided entirely in the project's root urls.py, the SAME catalog app could be mounted under a different prefix (say "library/") in another project, or even twice under two different prefixes in the same project, without changing a single line inside catalog/urls.py. - admin.site.urls is Django's own built-in admin routing (Chapter 8 covers the admin interface itself) — it's included the same way any app's URLs would be, just pointing at Django's internal admin app instead of one of your own.