(request, uid)
return render(request, "post_view.html", context=context)
Return a detailed view for specific post
Return a detailed view for specific post
Return a detailed view for specific post
def post_view(request, uid):
    "Return a detailed view for specific post"

    # Get the post.
    post = Post.objects.filter(uid=uid).select_related('root').first()
    user = request.user
    if not post:
        messages.error(request, "Post does not exist.")
        return redirect("post_list")

    # Redirect to post view
    if not post.is_toplevel:
        return redirect(post.get_absolute_url())

    # Return 404 when post is spam and user is anonymous.
    if post.is_spam and user.is_anonymous:
        raise Http404("Post does not exist.")

    # Form used for answers
    form = forms.PostShortForm(user=request.user, post=post)

    if request.method == "POST":
        form = forms.PostShortForm(data=request.POST, ptype=Post.ANSWER, user=request.user, post=post)
        if form.is_valid():
            answer = form.save()
            return redirect(answer.get_absolute_url())

        messages.error(request, form.errors)

    # Build the comment tree .
    root, comment_tree, answers, thread = auth.post_tree(user=request.user, root=post.root)

    # Bump post views.
    models.update_post_views(post=post, request=request, timeout=settings.POST_VIEW_TIMEOUT)

    context = dict(post=root, tree=comment_tree, form=form, answers=answers)

    return render(request, "post_view.html", context=context)
def post_view ( request , uid ) : # Get the post. post = Post . objects . filter ( uid = uid ) . select_related ( 'root' ) . first ( ) user = request . user if not post : messages . error ( request , "Post does not exist." ) return redirect ( "post_list" ) # Redirect to post view if not post . is_toplevel : return redirect ( post . get_absolute_url ( ) ) # Return 404 when post is spam and user is anonymous. if post . is_spam and user . is_anonymous : raise Http404 ( "Post does not exist." ) # Form used for answers form = forms . PostShortForm ( user = request . user , post = post ) if request . method == "POST" : form = forms . PostShortForm ( data = request . POST , ptype = Post . ANSWER , user = request . user , post = post ) if form . is_valid ( ) : answer = form . save ( ) return redirect ( answer . get_absolute_url ( ) ) messages . error ( request , form . errors ) # Build the comment tree . root , comment_tree , answers , thread = auth . post_tree ( user = request . user , root = post . root ) # Bump post views. models . update_post_views ( post = post , request = request , timeout = settings . POST_VIEW_TIMEOUT ) context = dict ( post = root , tree = comment_tree , form = form , answers = answers ) return render ( request , "post_view.html" , context = context )