Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2021
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. from django.views.generic import DetailView
  2. from books.models import Book, Publisher
  3.  
  4. class PublisherDetailView(DetailView):
  5.  
  6. model = Publisher
  7.  
  8. def get_context_data(self, **kwargs):
  9. # Call the base implementation first to get a context
  10. context = super().get_context_data(**kwargs)
  11. # Add in a QuerySet of all the books
  12. context['book_list'] = Book.objects.all()
  13. return context
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement