Hey Everyone,

I have a custon view set up which is basically a list of all the posts
within a category, which is paginated. Here is the code which I have
got working so far:

def category_detail(request, slug):

        recent_posts = Post.objects.order_by('-pub_date')[:10]
        category = shortcuts.get_object_or_404(Category, slug = slug)
        filtered_posts = Post.objects.filter(category__slug =
slug).order_by('pub_date')
        paginator_context = filtered_posts
        paginate_by = 2

        paginator = ObjectPaginator(paginator_context, paginate_by)

        try:
                page = int(request.GET.get('page', '1'))
                posts = paginator.get_page(page - 1)

        except InvalidPage:
                raise http.Http404
                posts = []

        return shortcuts.render_to_response('blog/category_detail.html', {
        'paginator': paginator,
        'posts': posts,
        'category': category,
        'is_paginated': paginator.pages > 1,
        'has_next': paginator.has_next_page(page - 1),
        'has_previous': paginator.has_previous_page(page - 1),
        'page': page,
        'next': page + 1,
        'previous': page - 1,
        'pages': paginator.pages,
        'hits' : paginator.hits,
        },
        context_instance = RequestContext(request))

All of that works fine, but I am wanting to do something like what is
documented at http://code.djangoproject.com/wiki/PaginatorTag - so it
will look like
http://www.jonathanbuchanan.plus.com/images/paginatortag02.png

After an hour or so of trying to put this code into my view - I have
given up. Can someone help me out with how to put this into my view.

Thank you so much in advance,
Oliver


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to