Hi Guys,
I see that this issue has been resolved. But in my case is still bugging me.
This is my code, could someone check it and see what i'am doing wrong please?
Here is my code:
@login_required
def add_comment_to_post(request,pk):
post = get_object_or_404(Post,pk=pk)
if request.method == 'POST':
form = CommentForm(request.POST)
if form.is_valid():
comment = form.save(commit=False)
# post is the pk in the model comment
comment.post = post
comment.save()
return redirect('blog:post_detail', pk=post.pk)
else:
form = CommentForm()
return render(request,'blog/comment_form.html',{'form':form})