Exemplo n.º 1
0
def landing(request):
    """
    Renders the landing page that aggregates all recent items
    """
    return object_list(
        request,
        queryset=Post.objects.all(),
        paginate_by=5,
        page=request.GET.get("page", 1),
        template_name="blog/landing.html",
        allow_empty=True,
        template_object_name="posts",
        extra_context={
            "pager_url": make_url_pattern(reverse("blog_landing"), request.GET),
        }
    )
Exemplo n.º 2
0
def tag_detail(request, tag):
    """
    Renders the tag detail page
    """
    return tagged_object_list(
        request,
        Post.objects,
        tag,
        paginate_by=5,
        page=request.GET.get("page", 1),
        allow_empty=True,
        template_name="blog/tag_detail.html",
        template_object_name="posts",
        extra_context={
            "pager_url": make_url_pattern(reverse("blog_tag_detail", kwargs={"tag": tag}), request.GET),
        }
    )
Exemplo n.º 3
0
def category_detail(request, slug):
    """
    Renders the blog category detail page
    """
    category = get_object_or_404(Category, slug=slug)
    
    return object_list(
        request,
        queryset=category.posts,
        paginate_by=5,
        page=request.GET.get("page", 1),
        template_name="blog/category_detail.html",
        allow_empty=True,
        template_object_name="posts",
        extra_context={
            "category": category,
            "pager_url": make_url_pattern(category.get_absolute_url(), request.GET),
        }
    )