This section states: “Each generic view needs to know what model it will be acting upon. This is provided using the
model attribute.”, right after the code example: a definition of a ListView based class, not using the aforementioned attribute.
class IndexView(generic.ListView): # Where's 'model'? template_name = 'polls/index.html' context_object_name = 'latest_question_list' def get_queryset(self): """Return the last five published questions.""" return Question.objects.order_by('-pub_date')[:5] class DetailView(generic.DetailView): model = Question ... * Each generic view needs to know...
I know it has a query inside a method, though, so maybe the text could be clearer, like “…using either a ‘model’ attribute, or a query”.
What am I missing?
In this case particularly, how does one know in advance that “This is provided by using the ‘model’ attribute.” doesn’t mean only that?