Guided Notes
Displaying Data: List & Detail Pages
Building list and detail pages, linking them with slugs, a master template, a custom 404 page, and class-based views.
The list page
Slide 1 / 5A list view fetches many objects and a template loops over them:
def book_list(request): books = Book.objects.select_related("author") return render(request, "library/book_list.html", {"books": books})
{% for book in books %} <a href="{% url 'book-detail' book.slug %}">{{ book.title }}</a> by {{ book.author.name }} {% endfor %}
