📜  在 django 中使用模板视图传递上下文数据 - Python 代码示例

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

代码示例1
class AboutView(TemplateView):
    template_name = 'about.html'

    def get_context_data(self, **kwargs):
        context = super(AboutView, self).get_context_data(**kwargs)
        context['dahl_books'] = Books.objects.filter(author="Dahl")
        return context