Как я могу получить 'pk' или 'id' в get_context_data
из CVB DetailView?
class MyDetail(DetailView):
model = Book
template_name = 'book.html'
def get_context_data(self, **kwargs):
context = super(MyDetail, self).get_context_data(**kwargs)
context['something'] = Book.objects.filter(pk=pk)
return context
URL:
url(r'^book/(?P<pk>\d+)/$', MyDetail.as_view(), name='book'),