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


Python pure_pagination.PageNotAnInteger方法代码示例

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


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

示例1: get_context_data

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import PageNotAnInteger [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 PageNotAnInteger [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 PageNotAnInteger [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 PageNotAnInteger [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: Home

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import PageNotAnInteger [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

示例6: ArticleList

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import PageNotAnInteger [as 别名]
def ArticleList(request):
    """
    文章list
    :param request:
    :return:
    """
    seo_list = get_object_or_404(Seo, name='文章')
    article = Article.objects.filter(is_show=True)
    category = Category_Article.objects.all().order_by('order')
    type = request.GET.get('type', '')
    try:
        page = request.GET.get('page', 1)
        if type:
            article =Article.objects.filter(category_id=type,is_show=True)
        if page == '':
            page = 1
    except PageNotAnInteger:
        page = 1
    # Provide Paginator with the request object for complete querystring generation
    p = Paginator(article,10,request=request)
    people = p.page(page)

    headlines = Headlines.objects.all()[:30]
    banners = Banners.objects.first()
    return render(request, 'pc/article.html', {'seo_list':seo_list,'article': people,'category':category,'Headlines':headlines,'banners':banners}) 
开发者ID:fengjinqi,项目名称:website,代码行数:27,代码来源:views.py

示例7: get

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import PageNotAnInteger [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

示例8: get

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import PageNotAnInteger [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

示例9: get

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import PageNotAnInteger [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

示例10: html_export

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import PageNotAnInteger [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

示例11: get_context_data

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import PageNotAnInteger [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

示例12: get

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import PageNotAnInteger [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

示例13: get

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import PageNotAnInteger [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

示例14: get

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import PageNotAnInteger [as 别名]
def get(self, request):
        message_board = MessageBoard.objects.order_by('-add_time')

        # 留言用户邮箱信息保密,将其中的部分字符转换成 * 号
        for message in message_board:
            name, addr = message.email.split('@')
            if len(name) > 5:
                name = name[0:3] + '*'*len(name[3:])
            else:
                addr = '*'*len(addr)
            message.email = name + '@' + addr

        # 用户留言分页
        old_message_page = request.session.get('message_board_page', 1)
        try:
            message_page = request.GET.get('message_page', 1)
            request.session['message_board_page'] = message_page
        except PageNotAnInteger:
            message_page = 1
        # 对数据库中所取出的所有对象,进行分页,中间的参数为每页显示的对象个数,设置为 6 个
        paginator = Paginator(message_board, 10, request=request, page_type='message_page')
        # 取出对应页的数据
        message_board_page = paginator.page(message_page)
        if old_message_page != message_page:
            message_focus = 'read'
        else:
            message_focus = 'add'
        return render(request, 'message.html', {
            'message': message_board_page,
            "focus": "message",
            "message_focus": message_focus
        }) 
开发者ID:fandiandian,项目名称:fansfood,代码行数:34,代码来源:views.py

示例15: get

# 需要导入模块: import pure_pagination [as 别名]
# 或者: from pure_pagination import PageNotAnInteger [as 别名]
def get(self, request):
        """排行榜的 get 方法"""
        food_list = FoodArticle.objects.order_by("-like")

        # 热门食物--做过的人最多
        popular_food = FoodArticle.objects.order_by("-fav")[:3]

        # 无数据的情况
        if food_list:
            message = True
        else:
            message = False

        # 获取页面传回的分页数值,默认为 1(第一页)
        try:
            page = request.GET.get('page', 1)
        except PageNotAnInteger:
            page = 1
        # 对数据库中所取出的所有对象,进行分页,中间的参数为每页显示的对象个数,设置为 6 个
        paginator = Paginator(food_list, 12, request=request)
        # 取出对应页的数据
        food_list_page = paginator.page(page)

        return render(request, 'food/food_ranking.html', {
            "food_list": food_list_page,
            "popular_food": popular_food,
            "message": message,
            "focus": "article",                              # 选中状态标志
        }) 
开发者ID:fandiandian,项目名称:fansfood,代码行数:31,代码来源:views.py


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