📜  获取上下文数据 django - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:01.576000             🧑  作者: Mango

代码示例1
class PublisherDetail(DetailView):

    model = Publisher

    def get_context_data(self, **kwargs):
        # Call the base implementation first to get a context
        context = super().get_context_data(**kwargs)
        # Add in a QuerySet of all the books
        context['book_list'] = Book.objects.all()
        return context