views.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:nrp 作者: django-rea 项目源码 文件源码
def comments(request):
    comments = Comment.objects.all().order_by("-submit_date")

    paginator = Paginator(comments, 25)
    page = request.GET.get('page')
    try:
        comment_list = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        comment_list = paginator.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999), deliver last page of results.
        comment_list = paginator.page(paginator.num_pages)
    return render_to_response("valueaccounting/comments.html", {
        "comment_list": comment_list,
    }, context_instance=RequestContext(request))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号