当前位置: 首页>>代码示例>>Python>>正文


Python pure_pagination.Paginator方法代码示例

本文整理汇总了Python中pure_pagination.Paginator方法的典型用法代码示例。如果您正苦于以下问题:Python pure_pagination.Paginator方法的具体用法?Python pure_pagination.Paginator怎么用?Python pure_pagination.Paginator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pure_pagination的用法示例。


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

示例1: get_context_data

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def get_context_data(self, **kwargs):
        try:
            page = self.request.GET.get('page', 1)
        except PageNotAnInteger as e:
            page = 1
        p = Paginator(self.queryset, getattr(settings, 'DISPLAY_PER_PAGE'), request=self.request)
        list = p.page(page)
        context = {
            "tasks_active": "active",
            "tools_results_active": "active",
            "tools_results_list": list,
            'date_from': (datetime.datetime.now() + datetime.timedelta(days=-7)).strftime('%Y-%m-%d'),
            'date_to': (datetime.datetime.now() + datetime.timedelta(days=+1)).strftime('%Y-%m-%d')
        }
        kwargs.update(context)
        return super().get_context_data(**kwargs) 
开发者ID:hequan2017,项目名称:chain,代码行数:18,代码来源:views.py

示例2: get_context_data

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def get_context_data(self, **kwargs):
        try:
            page = self.request.GET.get('page', 1)
        except PageNotAnInteger as e:
            page = 1
        p = Paginator(self.queryset, getattr(settings, 'DISPLAY_PER_PAGE'), request=self.request)
        list = p.page(page)

        context = {
            "crontab_active": "active",
            "crontab_periodictasks_result_active": "active",
            "periodictassks_results_list":list,
            'date_from': (datetime.datetime.now() + datetime.timedelta(days=-7)).strftime('%Y-%m-%d'),
            'date_to': (datetime.datetime.now() + datetime.timedelta(days=+1)).strftime('%Y-%m-%d')
        }

        kwargs.update(context)
        return super().get_context_data(**kwargs) 
开发者ID:hequan2017,项目名称:chain,代码行数:20,代码来源:views.py

示例3: get_context_data

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def get_context_data(self, **kwargs):
        """
        获取系统用户,再获取用户的组  根据组 去判断  资产所属的资产项目 是否 有 读取的权限
        :return:  返回有 读取权限的资产
        """
        try:
            page = self.request.GET.get('page', 1)
        except PageNotAnInteger as e:
            page = 1
        p = Paginator(self.queryset, getattr(settings,'DISPLAY_PER_PAGE'), request=self.request)

        asset_list = p.page(page)
        # 左侧导航站展开  "asset_active": "active",
        context = {
            "asset_active": "active",
            "asset_list_active": "active",
            "asset_list":asset_list,
            "web_ssh": getattr(settings, 'web_ssh'),
            "web_port": getattr(settings, 'web_port'),
        }
        kwargs.update(context)
        return super().get_context_data(**kwargs) 
开发者ID:hequan2017,项目名称:chain,代码行数:24,代码来源:views.py

示例4: get

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def get(self, request):
        all_message = UserMessage.objects.filter(user=request.user.id)

        # 用户进入个人中心消息页面,清空未读消息记录
        all_unread_messages = UserMessage.objects.filter(
            user=request.user.id, has_read=False)
        for unread_message in all_unread_messages:
            unread_message.has_read = True
            unread_message.save()
        # 对课程机构进行分页
        # 尝试获取前台get请求传递过来的page参数
        # 如果是不合法的配置参数默认返回第一页
        try:
            page = request.GET.get('page', 1)
        except PageNotAnInteger:
            page = 1
        # 这里指从allorg中取五个出来,每页显示5个
        p = Paginator(all_message, 4)
        messages = p.page(page)
        return render(request, "usercenter-message.html", {
            "messages": messages,
        }) 
开发者ID:mtianyan,项目名称:Mxonline3,代码行数:24,代码来源:views.py

示例5: index

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def index(request):
    """
    帖子首页
    :param request:
    :return:
    """
    seo_list = get_object_or_404(Seo, name='社区论坛')
    plate = Forum_plate.objects.all()
    forum = Forum.objects.filter(hidden=False).exclude(priority=Priority.objects.first())
    zd = Priority.objects.all()
    job = Forum.objects.filter(hidden=False,category__name='求职招聘')
    try:
        page = request.GET.get('page', 1)
        if page == '':
            page = 1
    except PageNotAnInteger:
        page = 1
        # Provide Paginator with the request object for complete querystring generation
    p = Paginator(forum, 10, request=request)
    people = p.page(page)
    return render(request,'pc/forum.html',locals()) 
开发者ID:fengjinqi,项目名称:website,代码行数:23,代码来源:views.py

示例6: indexMe

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def indexMe(request):
    """
    wd帖子首页
    :param request:
    :return:
    """
    plate = Forum_plate.objects.all()
    forum = Forum.objects.filter(hidden=False)
    count = User.objects.filter(follow__fan__id=request.user.id)
    floow = User.objects.filter(fan__follow_id=request.user.id)
    try:
        page = request.GET.get('page', 1)
        if page == '':
            page = 1
    except PageNotAnInteger:
        page = 1
        # Provide Paginator with the request object for complete querystring generation
    p = Paginator(forum, 10, request=request)
    people = p.page(page)
    return render(request,'pc/forum_me.html',locals()) 
开发者ID:fengjinqi,项目名称:website,代码行数:22,代码来源:views.py

示例7: forum_category

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def forum_category(request,category):
    """
    分类
    :param request:
    :param category:
    :return:
    """
    cate_list = Forum.objects.filter(category_id=category,hidden=False)
    plate = Forum_plate.objects.all()

    job = Forum.objects.filter(hidden=False,category__name='求职招聘')
    type = get_object_or_404(Forum_plate,pk=category)
    try:
        page = request.GET.get('page', 1)
        if page == '':
            page = 1
    except PageNotAnInteger:
        page = 1
        # Provide Paginator with the request object for complete querystring generation
    p = Paginator(cate_list, 20, request=request)
    people = p.page(page)

    return render(request,'pc/forum_category.html',locals()) 
开发者ID:fengjinqi,项目名称:website,代码行数:25,代码来源:views.py

示例8: Home

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def Home(request):
    """
    首页
    :param request:
    :return:
    """
    recommend = Recommend.objects.filter(is_recommend=True)[:10]

    qq = QQ.objects.all()
    links = link.objects.all()

    try:
        page = request.GET.get('page', 1)
        if page == '':
            page = 1
    except PageNotAnInteger:
        page = request.GET.get('page')
    # Provide Paginator with the request object for complete querystring generation
    dynamicList = dynamic.objects.filter(is_delete=False)[:500]

    dynamicPage = Paginator(dynamicList, 10, request=request).page(page)

    banners = Banners.objects.first()
    return render(request, 'pc/index.html', {'dynamicPage':dynamicPage}) 
开发者ID:fengjinqi,项目名称:website,代码行数:26,代码来源:views.py

示例9: get

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def get(self, request, item_id):
        item = Product.objects.get(id=int(item_id))
        all_review = item.get_review()

        try:
            page = request.GET.get('page', 1)
        except PageNotAnInteger:
            page = 1
        # 对评论进行分页
        p = Paginator(all_review, 5, request=request)

        reviews = p.page(page)

        return render(request, "product_item.html", {
            "item": item,
            "all_review": reviews,
        }) 
开发者ID:Liweimin0512,项目名称:ImitationTmall_Django,代码行数:19,代码来源:views.py

示例10: get

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def get(self, request):
        all_courses = Course.objects.all().order_by("-add_time")

        hot_courses = Course.objects.all().order_by("-click_nums")[:3]

        # -----------------站内课程搜索-----------------------
        search_keywords = request.GET.get('keywords', "")
        if search_keywords:
            # 在name字段进行操作,做like语句的操作。icontains中i代表不区分大小写
            # or操作使用Q
            all_courses = all_courses.filter(Q(name__icontains=search_keywords) | Q(desc__icontains=search_keywords) |
                                             Q(detail__icontains=search_keywords))
        # ------课程排序-----------
        sort = request.GET.get('sort', "")
        if sort:
            if sort == "students":
                all_courses = all_courses.order_by("-students")
            elif sort == "hot":
                all_courses = all_courses.order_by("-click_nums")
        # --------对课程进行分页----------------
        try:
            page = request.GET.get('page', 1)
        except PageNotAnInteger:
            page = 1
        p = Paginator(all_courses, 6, request=request)
        courses = p.page(page)

        return render(request, 'course-list.html', {
            "all_courses": courses,
            "sort": sort,
            "hot_courses": hot_courses
        })


# ----------------课程详情页---------------------------- 
开发者ID:stormsha,项目名称:StormOnline,代码行数:37,代码来源:views.py

示例11: get

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def get(self, request):
        all_teachers = Teacher.objects.all()

        # -----------------站内课程搜索-----------------------
        search_keywords = request.GET.get('keywords', '')
        if search_keywords:
            # 在name字段进行操作,做like语句的操作。i代表不区分大小写
            # or操作使用Q
            all_teachers = all_teachers.filter(Q(name__icontains=search_keywords) |
                                               Q(work_company__icontains=search_keywords) |
                                               Q(work_position__icontains=search_keywords)|
                                               Q(points__icontains=search_keywords))

        sort = request.GET.get('sort', "")
        if sort:
            if sort == "hot":
                all_teachers = all_teachers.order_by("-click_nums")
        # -------------讲师排行--------------------------------
        sorted_teacher = Teacher.objects.all().order_by("-click_nums")[:7]
        # -----讲师列表分页-----------------------------------------
        try:
            page = request.GET.get('page', 1)
        except PageNotAnInteger:
            page = 1

        p = Paginator(all_teachers, 3, request=request)

        teachers = p.page(page)
        return render(request, "teachers-list.html", {
            "all_teachers": teachers,
            "sorted_teacher": sorted_teacher,
            "sort": sort
        })


# ---------------------讲师详情页----------------------------- 
开发者ID:stormsha,项目名称:StormOnline,代码行数:38,代码来源:views.py

示例12: html_export

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def html_export(request, username, id_string):

    limit = request.REQUEST.get('limit', 100)
    # get_instances_for site_form
    cursor = get_instances_for_user_and_form(username, id_string)
    paginator = Paginator(cursor, limit, request=request)

    try:
        page = paginator.page(request.REQUEST.get('page', 1))
    except (EmptyPage, PageNotAnInteger):
        try:
            page = paginator.page(1)
        except (EmptyPage, PageNotAnInteger):
            page = None

    context = {
        'page': page,
        'table': []
    }

    if page:
        data = [("v1", page.object_list)]
        export = build_export(request, username, id_string)
        context['table'] = mark_safe("\n".join(export.to_html(data)))
        context['title'] = id_string

    return render(request, 'export/export_html.html', context) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:29,代码来源:views.py

示例13: get_context_data

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def get_context_data(self, **kwargs):
        try:
            page = self.request.GET.get('page', 1)
        except PageNotAnInteger as e:
            page = 1
        p = Paginator(self.queryset, getattr(settings, 'DISPLAY_PER_PAGE'), request=self.request)
        ecs_list = p.page(page)

        context = {
            "ecs_list": ecs_list,
            "filter_dict": self.filter_dict  # 把查询条件返回给前端
        }

        kwargs.update(context)
        return super().get_context_data(**kwargs) 
开发者ID:hequan2017,项目名称:seal,代码行数:17,代码来源:views.py

示例14: get

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def get(self, request):
        all_course = Course.objects.all()
        # 热门课程推荐
        hot_courses = Course.objects.all().order_by("-students")[:3]
        # 搜索功能
        search_keywords = request.GET.get('keywords', '')
        if search_keywords:
            # 在name字段进行操作,做like语句的操作。i代表不区分大小写
            # or操作使用Q
            all_course = all_course.filter(Q(name__icontains=search_keywords) | Q(
                desc__icontains=search_keywords) | Q(detail__icontains=search_keywords))
        # 对课程进行分页
        # 尝试获取前台get请求传递过来的page参数
        # 如果是不合法的配置参数默认返回第一页
        # 进行排序
        sort = request.GET.get('sort', "")
        if sort:
            if sort == "students":
                all_course = all_course.order_by("-students")
            elif sort == "hot":
                all_course = all_course.order_by("-click_nums")
        try:
            page = request.GET.get('page', 1)
        except PageNotAnInteger:
            page = 1
        # 这里指从all_org中取五个出来,每页显示5个
        p = Paginator(all_course, 6, request=request)
        courses = p.page(page)
        return render(request, "course-list.html", {
            "all_course": courses,
            "sort": sort,
            "hot_courses": hot_courses,
            "search_keywords": search_keywords
        }) 
开发者ID:mtianyan,项目名称:Mxonline3,代码行数:36,代码来源:views.py

示例15: get

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import Paginator [as 别名]
def get(self, request):
        all_teacher = Teacher.objects.all()
        sort = request.GET.get("sort", "")
        if sort:
            if sort == "hot":
                all_teacher = all_teacher.order_by("-click_nums")

        # 搜索功能
        search_keywords = request.GET.get('keywords', '')
        if search_keywords:
            # 在name字段进行操作,做like语句的操作。i代表不区分大小写
            # or操作使用Q
            all_teacher = all_teacher.filter(Q(name__icontains=search_keywords) | Q(
                work_company__icontains=search_keywords))

        # 排行榜讲师
        rank_teacher = Teacher.objects.all().order_by("-fav_nums")[:5]
        # 总共有多少老师使用count进行统计
        teacher_nums = all_teacher.count()
        # 对讲师进行分页
        # 尝试获取前台get请求传递过来的page参数
        # 如果是不合法的配置参数默认返回第一页
        try:
            page = request.GET.get('page', 1)
        except PageNotAnInteger:
            page = 1
        # 这里指从allorg中取五个出来,每页显示5个
        p = Paginator(all_teacher, 4, request=request)
        teachers = p.page(page)
        return render(request, "teachers-list.html", {
            "all_teacher": teachers,
            "teacher_nums": teacher_nums,
            "sort": sort,
            "rank_teachers": rank_teacher,
            "search_keywords": search_keywords,
        }) 
开发者ID:mtianyan,项目名称:Mxonline3,代码行数:38,代码来源:views.py


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