Пример #1
0
def group(request, gid):
    """
    Show blog's list by group
    """
    blogs = Blog.objects.filter(group_id=gid, status_id=2)
    group = Group.objects.get(id=gid)
    paginator = JuncheePaginator(blogs, 8)
    if request.method == 'GET' and 'page' in request.GET:
        page_num = int(request.GET.get('page'))
    else:
        page_num = 1

    try:
        blogs = paginator.page(page_num)
    except PageNotAnInteger:
        blogs = paginator.page(1)
    except EmptyPage:
        blogs = paginator.page(paginator.num_pages)

    return render_to_response('group.html', {'blogs': blogs, 'group' : group}, context_instance=RequestContext(request, processors=[new_blog, blog_group]))
Пример #2
0
def index(request):
    """
    Show blog's list
    """

    blogs = Blog.objects.filter(status_id=2) # Get released blogs
    #paginator = Paginator(blogs, 1)
    paginator = JuncheePaginator(blogs, 8)
    if request.method == 'GET' and 'page' in request.GET:
        page_num = int(request.GET.get('page'))
    else:
        page_num = 1
    try:
        blogs = paginator.page(page_num)
    except PageNotAnInteger:
        blogs = paginator.page(1)
    except EmptyPage:
        blogs = paginator.page(paginator.num_pages)

    return render_to_response("index.html", {'blogs':blogs}, context_instance=RequestContext(request, processors=[new_blog, blog_group]))