0
我有一個從基類繼承兩個基於類的觀點:訪問到父母的變量
class Base(object):
context_object_name = "book_list"
model = Book
def get_context_data(self, **kwargs):
context = super(Book, self).get_context_data(**kwargs)
return context
def get_queryset(self):
book_set = Book.objects.all()
return book_set
class C1(Base ,ListView):
paginate_by = 20
template_name = 'sl/v1.html'
class C2(Base, View):
template_name = 'sl/v2.html'
我需要做一些工藝上的查詢集結果C2類裏面。那麼我怎樣才能訪問C2中的book_list?
非常感謝madzohan。有用。 – mrbf 2014-10-22 10:49:17