It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 7 years ago.
I'm trying to do something like this:
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')
When I try to access dahl_books in my template like this:
{% for book in dahl_books %}
dahl_books
is not available in the template context, even though the Books QuerySet returned a non-zero number of books. ....am I doing something wrong in either my template or in get_context_data
?