當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。