更新时间:2023-11-17 18:00:04
def get_context_data(self, **kwargs):
context = super(DirectoryClass, self).get_context_data(**kwargs)
context['page'] = 'forum'
context['user'] = self.request.user
return context
def get_queryset(self):
directory = Directory.objects.filter(pk=self.kwargs['directory_id'])
topics = directory.first().topic_set.all().order_by('-last_post')
return topics
仅在您的ListView中使用此功能,因为Django为所有基于类的视图提供了分页功能
use this only in your ListView, as Django provides pagination to all the Class Based View