Personal Catalogue: Django & PostgreSQL — Chapter 4, Exercise 1 ==================================================== TASK Build both views, both templates, and the URL routing from this chapter, then confirm the list page correctly shows every item added through the admin in Chapter 3, tags included. SOLUTION 1. catalogue/views.py: from django.views.generic import ListView, DetailView from .models import Item class ItemListView(ListView): model = Item template_name = 'catalogue/item_list.html' context_object_name = 'items' paginate_by = 25 queryset = Item.objects.select_related('item_type').prefetch_related('tags') class ItemDetailView(DetailView): model = Item template_name = 'catalogue/item_detail.html' context_object_name = 'item' 2. catalogue/urls.py: from django.urls import path from . import views urlpatterns = [ path('', views.ItemListView.as_view(), name='item_list'), path('item//', views.ItemDetailView.as_view(), name='item_detail'), ] 3. catalogue_site/urls.py includes it: from django.urls import path, include from django.contrib import admin urlpatterns = [ path('admin/', admin.site.urls), path('', include('catalogue.urls')), ] 4. catalogue/templates/catalogue/base.html and item_list.html as given in the chapter, plus a matching item_detail.html rendering the single item's own title, creator, item_type, release_year, notes, and tags. CONFIRMING IT WORKS Run python manage.py runserver and visit the root URL. Every item added through the admin in Chapter 3 - the book, the CD, and the DVD - should appear on this page, with the book showing its own attached tags next to its title. Clicking an item's own title should navigate to its detail page at /item//. WHY THIS WORKS AS AN ANSWER ---------------------------- It reproduces the exact view, URL, and template code from the chapter in the correct file locations, and verifies the result against real data already in the database rather than freshly-added test data, confirming the admin and the public views genuinely share one table.