Start Detailview updating

Detailview updating

The code inside the loop creates a list item for each book that shows both the title (as a link to the yet-to-be-created detail view) and the author.

For these pages we're going to demonstrate a completely different type of view: generic class-based list and detail views.

These can significantly reduce the amount of view code needed, making them easier to write and maintain.

I would have thought the challenge would be a little more forgiving.

This tutorial extends our Local Library website, adding list and detail pages for books and authors.

The first is that you will need to include the actual form after the csrf token.

The second has to do with the challenge being really picky on the template code.

For example, you can specify another template file if you need to have multiple views that use this same model, or you might want to use a different template variable name if is not intuitive for your particular template use-case.

Possibly the most useful variation is to change/filter the subset of results that are returned — so instead of listing all books you might list top 5 books that were read by other users. List View): model = Book context_object_name = 'my_book_list' # your own name for the list as a template variable queryset = Book.objects.filter(title__icontains='war')[:5] # Get 5 books containing the title war template_name = 'books/my_arbitrary_template_name_list.html' # Specify your own template name/locationclass Book List View(generic.

Here we'll learn about generic class-based views, and show how they can reduce the amount of code you have to write for common use cases.

We'll also go into URL handling in greater detail, showing how to perform basic pattern matching.

We'll show both list and detail views after the next section.