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


Python paginator.PageNotAnInteger方法代码示例

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


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

示例1: get_paginated_memorials

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def get_paginated_memorials(self, filtered_memorials, request):
        items_per_page = 10

        paginator = Paginator(filtered_memorials, items_per_page)

        memorials_page = request.GET.get("page")

        try:
            paginated_memorials = paginator.page(memorials_page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            paginated_memorials = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            paginated_memorials = paginator.page(paginator.num_pages)

        return paginated_memorials 
开发者ID:WesternFriend,项目名称:WF-website,代码行数:19,代码来源:models.py

示例2: get

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def get(self, request):
        all_messages = 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_messages, 4)
        messages = p.page(page)
        return render(request, "usercenter-message.html", {
            "messages": messages
        })


# 首页view 
开发者ID:stormsha,项目名称:StormOnline,代码行数:26,代码来源:views.py

示例3: get_paginated_archive_issues

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def get_paginated_archive_issues(self, archive_issues, request):
        items_per_page = 9

        paginator = Paginator(archive_issues, items_per_page)

        archive_issues_page = request.GET.get("page")

        try:
            paginated_archive_issues = paginator.page(archive_issues_page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            paginated_archive_issues = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            paginated_archive_issues = paginator.page(paginator.num_pages)

        return paginated_archive_issues 
开发者ID:WesternFriend,项目名称:WF-website,代码行数:19,代码来源:models.py

示例4: get_context

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def get_context(self, request, *args, **kwargs):
        context = super().get_context(request)

        upcoming_events = Event.objects.all().filter(
            Q(date__gt=date.today())).order_by('date')

        # Show three archive issues per page
        paginator = Paginator(upcoming_events, 3)

        upcoming_events_page = request.GET.get("page")

        try:
            paginated_events = paginator.page(upcoming_events_page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            paginated_events = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            paginated_events = paginator.page(paginator.num_pages)

        context["events"] = paginated_events

        return context 
开发者ID:WesternFriend,项目名称:WF-website,代码行数:25,代码来源:models.py

示例5: search_category

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def search_category(request, id):
    posts = Article.objects.filter(category_id=str(id))
    category = categories.get(id=str(id))
    paginator = Paginator(posts, settings.PAGE_NUM)  # 每页显示数量
    try:
        page = request.GET.get('page')  # 获取URL中page参数的值
        post_list = paginator.page(page)
    except PageNotAnInteger:
        post_list = paginator.page(1)
    except EmptyPage:
        post_list = paginator.page(paginator.num_pages)
    return render(request, 'category.html',
                  {'post_list': post_list,
                   'category_list': categories,
                   'category': category,
                   'months': months
                  }
    ) 
开发者ID:nature1995,项目名称:ran-django-template,代码行数:20,代码来源:views.py

示例6: search_tag

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def search_tag(request, tag):
    posts = Article.objects.filter(tags__name__contains=tag)
    paginator = Paginator(posts, settings.PAGE_NUM)  # 每页显示数量
    try:
        page = request.GET.get('page')  # 获取URL中page参数的值
        post_list = paginator.page(page)
    except PageNotAnInteger:
        post_list = paginator.page(1)
    except EmptyPage:
        post_list = paginator.page(paginator.num_pages)
    return render(request, 'tag.html', {
        'post_list': post_list,
        'category_list': categories,
        'tag': tag,
        'months': months
        }
    ) 
开发者ID:nature1995,项目名称:ran-django-template,代码行数:19,代码来源:views.py

示例7: archives

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def archives(request, year, month):
    posts = Article.objects.filter(pub_time__year=year, pub_time__month=month).order_by('-pub_time')
    paginator = Paginator(posts, settings.PAGE_NUM)  # 每页显示数量
    try:
        page = request.GET.get('page')  # 获取URL中page参数的值
        post_list = paginator.page(page)
    except PageNotAnInteger:
        post_list = paginator.page(1)
    except EmptyPage:
        post_list = paginator.page(paginator.num_pages)
    return render(request, 'archive.html', {
        'post_list': post_list,
        'category_list': categories,
        'months': months,
        'year_month': year+'.'+month
        }
    ) 
开发者ID:nature1995,项目名称:ran-django-template,代码行数:19,代码来源:views.py

示例8: validate_number

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def validate_number(self, number):
        """
        Validates the given 1-based page number.
        """
        try:
            number = int(number)
        except (TypeError, ValueError):
            raise PageNotAnInteger('That page number is not an integer')
        if number < 1:
            raise EmptyPage('That page number is less than 1')
        if number > self.num_pages:
            if number == 1 and self.allow_empty_first_page:
                pass
            else:
                number = self.num_pages
        return number 
开发者ID:momosecurity,项目名称:aswan,代码行数:18,代码来源:generic.py

示例9: dashboard

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def dashboard(request):
    bls = BusinessLine.authorization.for_user(request.user, 'incidents.view_incidents')
    bl_filter = Q(business_line__in=bls) | Q(business_line__isnull=True)
    todos = TodoItem.objects.filter(incident__isnull=False, done=False).filter(bl_filter)
    todos = todos.select_related('incident', 'category')
    todos = todos.order_by('-incident__date')

    page = request.GET.get('page', 1)
    todos_per_page = request.user.profile.incident_number
    p = Paginator(todos, todos_per_page)

    try:
        todos = p.page(page)
    except (PageNotAnInteger, EmptyPage):
        todos = p.page(1)

    return render(request, 'fir_todos/dashboard.html', {'todos': todos}) 
开发者ID:certsocietegenerale,项目名称:FIR,代码行数:19,代码来源:views.py

示例10: page_it

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def page_it(data, record_per_page, page=''):
    """
        return the data of the current page
    """
    paginator = Paginator(data, record_per_page)
    try:
        data = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        data = paginator.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999),
        # deliver last page of results.
        data = paginator.page(paginator.num_pages)

    return data 
开发者ID:push-things,项目名称:dj-diabetes,代码行数:18,代码来源:tools.py

示例11: get_context_data

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def get_context_data(self, **kwargs):
        logger.debug('GET: ListMissionView')
        context = super(ListMissionView, self).get_context_data(**kwargs)
        missions = Mission.objects.all()
        paginator = Paginator(missions, 10)
        page = self.request.GET.get('page')
        try:
            show_missions = paginator.page(page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            show_missions = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            show_missions = paginator.page(paginator.num_pages)
        context['missions'] = show_missions
        return context 
开发者ID:lmco,项目名称:dart,代码行数:18,代码来源:views.py

示例12: comment_list

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def comment_list(request, post_id):
    post = Post.objects.get(id=post_id)
    comments_all_list = Comment.objects.filter(post=post, is_deleted=False).order_by('-id')

    paginator = Paginator(comments_all_list, post.board.comments_chunk_size)
    page = request.GET.get('page')

    try:
        comments = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        comments = paginator.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999), deliver last page of results.
        comments = paginator.page(paginator.num_pages)

    pages_nav_info = get_pages_nav_info(comments, nav_chunk_size=post.board.comment_pages_nav_chunk_size)

    return render(request, 'comment_list.html', {
        'post': post,
        'comments': comments,
        'pages_nav_info': pages_nav_info
    }) 
开发者ID:kboard,项目名称:kboard,代码行数:25,代码来源:views.py

示例13: index

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def index(request):
	POSTS_PER_PAGE = 5
	
	if request.user.is_superuser:
		post_list = Post.objects.all().order_by('-post_date')
	else:
		#post_list = Post.objects.filter(published=True).order_by('-post_date')
		post_list = get_Posts_By_Language_Code(request.LANGUAGE_CODE)

	paginator = Paginator(post_list, POSTS_PER_PAGE)

	page = request.GET.get('page')
	try:
		posts = paginator.page(page)
	except PageNotAnInteger:
		# If page is not an integer, deliver first page.
		posts = paginator.page(1)
	except EmptyPage:
		# If page is out of range, deliver last page of results.
		posts = paginator.page(paginator.num_pages)

	return render(request, 'blogApp/index.html', {'posts': posts}) 
开发者ID:SPARLab,项目名称:BikeMaps,代码行数:24,代码来源:index.py

示例14: query_job

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def query_job(request):
    if request.user.is_superuser:
        job_list = Queue.objects.order_by('-create_time').all()
    else:
        job_list = Queue.objects.filter(user_id=request.user.id).order_by('-create_time').all()
    paginator = Paginator(job_list, 12)

    page = request.GET.get('page')
    '''
    try:
        jobs = paginator.page(page)
    except PageNotAnInteger:
        jobs = paginator.page(1)
    except EmptyPage:
        jobs = paginator.page(paginator.num_pages)
    '''
    jobs = page_info(paginator, page)
    dt, du, dp = get_disk_quota_info(request.user.id)
    return render(request, 'ui/query_job.html', {'job_list': jobs, 't_disk': dt, 'u_disk': du, 'disk_per': dp}) 
开发者ID:liyao001,项目名称:BioQueue,代码行数:21,代码来源:views.py

示例15: get_paginated

# 需要导入模块: from django.core import paginator [as 别名]
# 或者: from django.core.paginator import PageNotAnInteger [as 别名]
def get_paginated(request, obj_list, obj_per_page=30):
    limit = request.GET.get('limit')
    if limit:
        obj_per_page = min(int(limit), 500)

    paginator = Paginator(obj_list, obj_per_page)

    page = request.GET.get('page')
    try:
        objs = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        objs = paginator.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999), deliver last page of results.
        objs = paginator.page(paginator.num_pages)
    objs.limit = obj_per_page
    copy_get = request.GET.copy()
    if copy_get.get('page'):
        del copy_get['page']
    copy_get['limit'] = obj_per_page
    objs.get_params = copy_get.urlencode()
    return objs 
开发者ID:idaholab,项目名称:civet,代码行数:25,代码来源:views.py


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