예제 #1
0
def Project(request):
    post = Post.objects.filter(post_type='project').first()
    if post:
        md = MD()
        post.body = md.convert(post.body)
        post.toc = md.toc
        post.increase_views() # 调用 increase_views 方法,统计访问量
        return render(request, 'blog/project.html', context={'post': post})
    else:
        return page_not_found(request)
예제 #2
0
def Project(request):
    post = Post.objects.filter(is_show=True, post_type='project').first()
    if post:
        post.increase_views()  # 调用 increase_views 方法,统计访问量
        comments_dict = comment_reply_content(post_id=post.id)  # 评论回复
        comment_form = CommentForm()  # 引入评论表单
        context = {
            'post': post,
            'comments_dict': comments_dict,
            'comment_form': comment_form,
        }
        return render(request, 'blog/project.html', context=context)
    else:
        return page_not_found(request)