老师你好:
我在 ListView 下使用 get_queryset() 方法,为什么模型类的所有方法都不可用了?
模型类的字段全部都是可以调用的。
class QuestionListView(ListView):
""" Question list page view """
model = QuestionModel
paginate_by = 100
context_object_name = 'question_list'
template_name = 'question/list.html'
def get_queryset(self):
super_queryset = super(QuestionListView, self).get_queryset()
queryset = super_queryset.filter(status=QuestionModel.OPEN).values('title', 'viewed', 'slug', 'updated_at') \
.order_by('-updated_at')
return queryset