multiple pagination in django class based view

笑着哭i 提交于 2020-01-06 15:24:51

问题


The code below paginates the queryset but how can I paginate context['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

来源:https://stackoverflow.com/questions/24336284/multiple-pagination-in-django-class-based-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!