Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. def add_comment(request, post_id):
  2.     post_ = Post.objects.get(pk=post_id)
  3.     if request.method == 'POST':
  4.         form = CommentForm(request.POST)
  5.         if form.is_valid():
  6.             post_.comment_set.add(form)
  7.     else:
  8.         form = CommentForm()
  9.     return render(request, 'blog/add_comment.html', {"form": form})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement