Now I have the following code in the views.py
:
class IndexView(generic.ListView):
model = Question
template_name = "qa_forum/index.html"
context_object_name = 'question_list'
paginate_by = 25
Its work good, but it retrieves all questions in the database (including closed and "future" questions).
In the models.py
I have the following manager:
class ActiveManager(models.Manager):
def get_query_set(self):
return super(ActiveManager, self).get_query_set(). \
.filter(pub_date__lte=timezone.now(), is_active=True
).order_by('-pub_date')
That helps to get only active question from the db.
But I don't know how to use it properly with the generic ListView
.
Any advice would be greatly appreciated.