예제 #1
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     context.update({
         'sidebars': SideBar.get_all(),
     })
     context.update(Category.get_nav())
     return context
예제 #2
0
def post_detail(request, post_id=None):
    try:
        post = Post.objects.get(id=post_id)
    except Post.DoesNotExist:
        post = None

    context = {
        'post': post,
        "sidebars": SideBar.get_all(),
    }

    context.update(Category.get_nav())

    return render(request, 'blog/detail.html', context={"post": post})
예제 #3
0
def post_list(request, category_id=None, tag_id=None):
    tag = None
    category = None

    if tag_id:
        tag, p_list = Post.get_by_tag(tag_id)
    elif category_id:
        p_list, category = Post.get_by_category(category_id)
    else:
        p_list = Post.latest_posts()
    context = {
        "category": category,
        "tag": tag,
        "post_list": p_list,
        "sidebars": SideBar.get_all()
    }

    context.update(Category.get_nav())

    return render(request, 'blog/list.html', context=context)