Wie kann ich 'pk' oder 'id' in get_context_data
von CVB DetailView bekommen?Wie kann ich "pk" oder "id" in "get_context_data" von CVB bekommen?
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'),
In Vorlage wie 'something.0.pk' –
ich aufgrund CVB verwirrt tun bedeutet, dass Sie Class Based Views (CBV)? .. –