以下代码对查询集进行分页,但如何对上下文进行分页[' guser1']
class AuthorList(ListView):
template_name = 'authorList.html'
paginate_by = 10
queryset = Author.objects.order_by('date')
def get_context_data(self, **kwargs):
context = super(AuthorList, self).get_context_data(**kwargs)
if int(self.kwargs['user_id']) != self.request.user.id:
raise PermissionDenied
if self.request.user.username == 'guest':
raise PermissionDenied
context['guser1'] = Author.objects.order_by('date').filter(
real_date__lte=datetime.now()).filter(
created_by=int(self.kwargs['user_id']))
context['guser'] = User.objects.filter(pk=int(self.kwargs['user_id']))
return context