我正在尝试做这样的事情:
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')
当我尝试像这样在我的模板中访问 dahl_books 时:
{% for book in dahl_books %}
dahl_books
在模板上下文中不可用,即使 Books QuerySet 返回了非零数量的书籍。....我在模板或模板中做错了get_context_data
什么?