• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python shortcuts.paginate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.shortcuts.paginate函数的典型用法代码示例。如果您正苦于以下问题:Python paginate函数的具体用法?Python paginate怎么用?Python paginate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了paginate函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: questanswer

def questanswer(request, page=None):
    context = RequestContext(request)
    context['title'] = u'Вопрос-ответ'
    if request.method == 'POST':
        context['author_error'] = False
        context['mes_error'] = False

        if not request.POST.get('q_autor', ''):
            context['author_error'] = True
        else:
            context['q_autor'] = request.POST['q_autor']
        
        if not request.POST.get('q_mes', ''):
            context['mes_error'] = True
        else:
            context['q_mes'] = request.POST['q_mes']
        
        if context['author_error'] or context['mes_error']:
            pass
        else:
            qa = QuestAnswer(author = context['q_autor'], question = context['q_mes'])
            qa.save()
            context['ok'] = True
    context['unanswered'] = QuestAnswer.objects.order_by('-date_publication').filter(is_public=False)
    context['tags'] = TagName.objects.all()
    context['alphabet'] = Alphabet.objects.filter(is_action=True).order_by('letter')
    paginate(
        context, 'questanswer', 
        QuestAnswer.objects.order_by('-date_publication').filter(is_public=True),
        count=QA_ON_PAGE, page=page, 
        root=context['current_section'].path
    )
    return render_to_response('qa/questanswer.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:33,代码来源:views.py


示例2: section

def section(request, section, page=None):
    context = RequestContext(request)
    paginate(
        context, 'articles', 
        query=context['section'].article_set.all(),
        count=ARTICLES_ON_PAGE, page=page, 
        root=request.current_section.path+section+'/'
    )
    return render_to_response('articles/section.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:9,代码来源:views.py


示例3: index

def index(request, page=None):
    context = RequestContext(request)
    paginate(
        context, 'articles', 
        Article.objects.order_by('-date_written'),
        count=ARTICLES_ON_PAGE, page=page, 
        root=request.current_section.path
    )
    return render_to_response('articles/index.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:9,代码来源:views.py


示例4: action_list

def action_list(request, page=None):
    context = get_default_context(request)
    context['actions'] = Action.objects.filter(is_active=True)
    paginate(
        context, 'actions', 
        Action.objects.filter(is_active=True).order_by('-id'),
        count=COLLECTIONS_ON_PAGE, page=page, 
        root=context['current_section'].path
    )
    context['disables'] = Action.objects.filter(is_active=False).order_by('-id')
    return render_to_response('action/action.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:11,代码来源:views.py


示例5: tag

def tag(request, tag, page=None):
    context = RequestContext(request)
    groups = Group.objects.all().order_by('id').values()
    context['groups'] = build_tree(groups, 'group_id')
    context['tagview'] = get_object_or_404(Tag, name=tag)
    paginate(
        context, 'articles', 
        query=Article.objects.filter(tags__name__exact=tag).order_by('-date_written'),
        count=ARTICLES_ON_PAGE, page=page, 
        root=request.current_section.path+tag+'/'
    )
    return render_to_response('articles/tag.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:12,代码来源:views.py


示例6: section

def section(request, section, page=None):
    context = RequestContext(request)
    groups = Group.objects.all().order_by('id').values()
    context['groups'] = build_tree(groups, 'group_id')
    context['section'] = get_object_or_404(Group, name=section)
    paginate(
        context, 'articles', 
        query=context['section'].article_set.all(), 
        count=ARTICLES_ON_PAGE, page=page, 
        root=request.current_section.path+section+'/'
    )
    return render_to_response('articles/section.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:12,代码来源:views.py


示例7: index

def index(request, page=None):
    context = RequestContext(request)
    # create_widgets_context(context, 'articles_index', 1, 1)
    groups = Group.objects.all().order_by('id').values()
    context['groups'] = build_tree(groups, 'group_id')
    paginate(
        context, 'articles', 
        Article.objects.order_by('-date_written'),
        count=ARTICLES_ON_PAGE, page=page, 
        root=request.current_section.path
    )
    return render_to_response('articles/index.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:12,代码来源:views.py


示例8: action_item

def action_item(request, slug, page=None):
    context = get_default_context(request)
    context['action'] = get_object_or_404(Action, slug=slug)
    context['crumbs'].append({
      'caption': context['action'].name,
      'path': slug,
    })
    paginate(
        context, 'positions', 
        query=Action.objects.get(slug=slug).products.all().filter(is_enabled=True),
        count=PRODUCTS_ON_PAGE, page=page, 
        root=context['current_section'].path+slug+'/'
    )
    return render_to_response('action/action-item.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:14,代码来源:views.py


示例9: get

    def get(self, request):
        """
        比赛题目分页json api接口
        ---
        response_serializer: ContestProblemSerializer
        """
        contest_problem_id = request.GET.get("contest_problem_id", None)
        if contest_problem_id:
            try:
                contest_problem = ContestProblem.objects.get(id=contest_problem_id)
                if request.user.admin_type != SUPER_ADMIN and contest_problem.created_by != request.user:
                    return error_response(u"比赛题目不存在")
                return success_response(ContestProblemSerializer(contest_problem).data)
            except ContestProblem.DoesNotExist:
                return error_response(u"比赛题目不存在")

        contest_problems = ContestProblem.objects.all().order_by("sort_index")
        if request.user.admin_type != SUPER_ADMIN:
            contest_problems = contest_problems.filter(created_by=request.user).order_by("sort_index")
        visible = request.GET.get("visible", None)
        if visible:
            contest_problems = contest_problems.filter(visible=(visible == "true"))
        keyword = request.GET.get("keyword", None)
        if keyword:
            contest_problems = contest_problems.filter(Q(title__contains=keyword) |
                                                       Q(description__contains=keyword))
        contest_id = request.GET.get("contest_id", None)
        if contest_id:
            contest_problems = contest_problems.filter(contest__id=contest_id).order_by("sort_index")

        return paginate(request, contest_problems, ContestProblemSerializer)
开发者ID:adamwen829,项目名称:OnlineJudge,代码行数:31,代码来源:views.py


示例10: get

    def get(self, request):
        """
        题目分页json api接口
        ---
        response_serializer: ProblemSerializer
        """
        problem_id = request.GET.get("problem_id", None)
        if problem_id:
            try:
                # 普通管理员只能获取自己创建的题目
                # 超级管理员可以获取全部的题目
                problem = Problem.objects.get(id=problem_id)
                if request.user.admin_type != SUPER_ADMIN and problem.created_by != request.user:
                    return error_response(u"题目不存在")
                return success_response(ProblemSerializer(problem).data)
            except Problem.DoesNotExist:
                return error_response(u"题目不存在")

        # 获取问题列表
        problems = Problem.objects.all().order_by("-create_time")

        if request.user.admin_type != SUPER_ADMIN:
            problems = problems.filter(created_by=request.user)

        visible = request.GET.get("visible", None)
        if visible:
            problems = problems.filter(visible=(visible == "true"))
        keyword = request.GET.get("keyword", None)
        if keyword:
            problems = problems.filter(Q(title__contains=keyword) |
                                       Q(description__contains=keyword))

        return paginate(request, problems, ProblemSerializer)
开发者ID:8cbx,项目名称:OnlineJudge,代码行数:33,代码来源:views.py


示例11: get

 def get(self, request):
     """
     查询小组列表或者单个小组的信息,查询单个小组需要传递group_id参数,否则返回全部
     ---
     response_serializer: GroupSerializer
     """
     group_id = request.GET.get("group_id", None)
     # 根据 id 查询小组信息
     if group_id:
         try:
             group = self.get_group(request, group_id)
             return success_response(GroupSerializer(group).data)
         except Group.DoesNotExist:
             return error_response(u"小组不存在")
     else:
         groups = self.get_groups(request)
         # 搜索小组
         if request.GET.get("keyword", None):
             groups = groups.filter(name__contains=request.GET["keyword"])
         # 只返回我创建的小组 适用于超级管理员
         if request.GET.get("my_group", None):
             groups = groups.filter(admin=request.user)
         # 只返回指定用户的小组 适用于管理员
         elif request.GET.get("admin_id", None):
             groups = groups.filter(admin__id=request.GET["admin_id"])
         return paginate(request, groups, GroupSerializer)
开发者ID:isheng5,项目名称:OnlineJudge,代码行数:26,代码来源:views.py


示例12: get

 def get(self, request):
     """
     查询比赛提交,单个比赛题目提交的adminAPI
     ---
     response_serializer: SubmissionSerializer
     """
     problem_id = request.GET.get("problem_id", None)
     contest_id = request.GET.get("contest_id", None)
     if contest_id:
         try:
             contest = Contest.objects.get(pk=contest_id)
         except Contest.DoesNotExist:
             return error_response(u"比赛不存在!")
         if request.user.admin_type != SUPER_ADMIN and contest.created_by != request.user:
             return error_response(u"您无权查看该信息!")
         submissions = Submission.objects.filter(contest_id=contest_id).order_by("-create_time")
     else:
         if problem_id:
             try:
                 contest_problem = ContestProblem.objects.get(pk=problem_id)
             except ContestProblem.DoesNotExist:
                 return error_response(u"问题不存在!")
             if request.user.admin_type != SUPER_ADMIN and contest_problem.contest.created_by != request.user:
                 return error_response(u"您无权查看该信息!")
             submissions = Submission.objects.filter(contest_id=contest_problem.contest_id).order_by("-create_time")
         else:
             return error_response(u"参数错误!")
     if problem_id:
         submissions = submissions.filter(problem_id=problem_id)
     return paginate(request, submissions, SubmissionSerializer)
开发者ID:hujingguang,项目名称:OnlineJudge,代码行数:30,代码来源:views.py


示例13: get

 def get(self, request):
     """
     公告分页json api接口
     ---
     response_serializer: AnnouncementSerializer
     """
     announcement = Announcement.objects.all().order_by("-create_time")
     visible = request.GET.get("visible", None)
     if visible:
         announcement = announcement.filter(visible=(visible == "true"))
     return paginate(request, announcement, AnnouncementSerializer)
开发者ID:ArchFeh,项目名称:OnlineJudge,代码行数:11,代码来源:views.py


示例14: get

 def get(self, request):
     """
     公告分页json api接口
     ---
     response_serializer: AnnouncementSerializer
     """
     if request.user.admin_type == SUPER_ADMIN:
         announcement = Announcement.objects.all().order_by("-last_update_time")
     else:
         announcement = Announcement.objects.filter(created_by=request.user)
     visible = request.GET.get("visible", None)
     if visible:
         announcement = announcement.filter(visible=(visible == "true"))
     return paginate(request, announcement, AnnouncementSerializer)
开发者ID:uestcxl,项目名称:OnlineJudge,代码行数:14,代码来源:views.py


示例15: get

    def get(self, request):
        """
        查询小组成员的api,需要传递group_id参数
        ---
        response_serializer: GroupMemberSerializer
        """
        group_id = request.GET.get("group_id", None)
        if not group_id:
            return error_response(u"参数错误")
        try:
            group = self.get_group(request, group_id)
        except Group.DoesNotExist:
            return error_response(u"小组不存在")

        return paginate(request, UserGroupRelation.objects.filter(group=group), GroupMemberSerializer)
开发者ID:localfunction,项目名称:OnlineJudge,代码行数:15,代码来源:views.py


示例16: get

    def get(self, request):
        """
        查询比赛提交,单个比赛题目提交的adminAPI
        ---
        response_serializer: SubmissionSerializer
        """
        problem_id = request.GET.get("problem_id", None)
        contest_id = request.GET.get("contest_id", None)

        # 需要 problem_id 和 contest_id 两个参数 否则会在check_user_contest_permission 的时候被拦截
        if problem_id:
            submissions = Submission.objects.filter(contest_id=contest_id, problem_id=problem_id).order_by("-create_time")
        # 需要 contest_id 参数
        else:
            submissions = Submission.objects.filter(contest_id=contest_id).order_by("-create_time")

        return paginate(request, submissions, SubmissionSerializer)
开发者ID:kdwycz,项目名称:OnlineJudge,代码行数:17,代码来源:views.py


示例17: get

    def get(self, request):
        """
        题目分页json api接口
        ---
        response_serializer: ProblemSerializer
        """
        problem_id = request.GET.get("problem_id", None)
        if problem_id:
            try:
                problem = Problem.objects.get(id=problem_id)
                return success_response(ProblemSerializer(problem).data)
            except Problem.DoesNotExist:
                return error_response(u"题目不存在")
        problem = Problem.objects.all().order_by("-create_time")
        visible = request.GET.get("visible", None)
        if visible:
            problem = problem.filter(visible=(visible == "true"))
        keyword = request.GET.get("keyword", None)
        if keyword:
            problem = problem.filter(Q(title__contains=keyword) |
                                     Q(description__contains=keyword))

        return paginate(request, problem, ProblemSerializer)
开发者ID:pathminer,项目名称:OnlineJudge,代码行数:23,代码来源:views.py


示例18: catalog_list

def catalog_list(request, page=None):
    context = get_default_context(request)
    # Getting catalog for the section
    # @todo improve! o___O
    cs = context['current_section']
    if cs.path != '/catalog/':
        if Catalog.objects.filter(section=cs):
            context['catalog'] = Catalog.objects.get(section=cs)
        elif Catalog.objects.filter(section=cs.parent):
            context['catalog'] = Catalog.objects.get(section=cs.parent)
        elif Catalog.objects.filter(section=cs.parent.parent):
            context['catalog'] = Catalog.objects.get(section=cs.parent.parent)
        else:
            context['catalog'] = Catalog.objects.get(section=cs.parent.parent.parent)
        context['catalog_properties'] = context['catalog'].properties.all()
    else:
        context['catalog'] = None
        context['catalog_properties'] = []
        
    for p in context['catalog_properties']:
        if p.type == 4:
            fv = request.GET.getlist(p.slug)
            if fv is not None:
                arr = []
                for v in fv:
                    arr.append(int(v))
                p.filtered_values = arr
        else:
            fv = request.GET.get(p.slug)
            if fv is not None:
                p.filtered_value = fv
    
    # Is it terminal section or not?
    if context['current_section'].has_children():
        # Non-terminal section
        context['subsections'] = context['current_section'].children.filter(is_enabled=True)
        current_path = context['current_section'].path
        descendants_ids = Section.objects.filter(path__startswith=current_path).values('id')
        descendants_ids = [x['id'] for x in descendants_ids]
        if context['aphaline_edit_mode']:
            paginate(
                context, 'catalog_positions', 
                Product.objects.filter(section__in=descendants_ids) \
                                .filter(is_exist=True).order_by('-is_enabled', '-order'),
                count=PRODUCTS_ON_PAGE, page=page, 
                root=context['current_section'].path
            )
        else:
            paginate(
                context, 'catalog_positions', 
                Product.objects.filter(section__in=descendants_ids) \
                                .filter(is_exist=True, is_enabled=True).order_by('-order'),
                count=PRODUCTS_ON_PAGE, page=page, 
                root=context['current_section'].path
            )
        return render_to_response('catalog/list_nonterminal.html', context)
    else:
        if context['aphaline_edit_mode']:
            paginate(
                context, 'catalog_positions', 
                Product.objects.filter(section=context['current_section']).order_by('-is_enabled', '-is_exist', '-order'),
                count=PRODUCTS_ON_PAGE, page=page, 
                root=context['current_section'].path
            )
        else:
            paginate(
                context, 'catalog_positions', 
                Product.objects.filter(section=context['current_section'], is_enabled=True).order_by('-is_exist', '-order'),
                count=PRODUCTS_ON_PAGE, page=page, 
                root=context['current_section'].path
            )
        return render_to_response('catalog/list_terminal.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:72,代码来源:views.py


示例19: get

 def get(self, request):
     problem_id = request.GET.get("problem_id", None)
     if not problem_id:
         return error_response(u"参数错误")
     submissions = Submission.objects.filter(problem_id=problem_id, contest_id__isnull=True).order_by("-create_time")
     return paginate(request, submissions, SubmissionSerializer)
开发者ID:mcmdhr,项目名称:CSOJ,代码行数:6,代码来源:views.py



注:本文中的utils.shortcuts.paginate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python shortcuts.rand_str函数代码示例发布时间:2022-05-26
下一篇:
Python shortcuts.error_response函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap