Guest User

Untitled

a guest
Jun 29th, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. class BookDetailView(DetailView):
  2.     model = Book
  3.     slug_field = 'url'
  4.     slug_url_kwarg = 'url'
  5.  
  6.     def get_context_data(self, *args, **kwargs):
  7.         context = super().get_context_data(*args, **kwargs)
  8.         context['title'] = Book.objects.filter(url=self.kwargs['url']).first()
  9.         return context
  10.  
  11.     def cart_book_form(request):
  12.         cart_book_form = CartAddBookForm()
  13.         return render(request, 'catalog/detail.html', {'book': book, 'cart_book_form': cart_book_form})
Advertisement
Add Comment
Please, Sign In to add comment