Beispiel #1
0
def home(request):
    """ Home Page """
    
    pager = ObjectPaginator(Post.objects.all(), 10)
    pager.page = int(request.GET.get("sayfa", 1))
    
    try:
        posts = pager.get_page(pager.page - 1)
    except:
        posts = None
    
    pager.url = make_url_pattern(reverse("home"), request.GET)
    
    return render_to_response("entries/home.html", {
        "posts" : posts,
        "pager" : pager
    }, context_instance=RequestContext(request))
Beispiel #2
0
def category_detail(request, slug):
    """ Category detail page """
    
    category = get_object_or_404(Category.objects, slug=slug)
    
    pager = ObjectPaginator(Post.objects.filter(category=category), 10)
    pager.page = int(request.GET.get("sayfa", 1))
    
    try:
        posts = pager.get_page(pager.page - 1)
    except:
        posts = None
    
    pager.url = make_url_pattern(reverse("category_detail", kwargs={"slug": slug}), request.GET)
    
    return render_to_response("entries/category_detail.html", {
        "category" : category,
        "posts" : posts,
        "pager" : pager
    }, context_instance=RequestContext(request))