Skip to content

didn't return an HttpResponse object. It returned None instead #13

@Misterlae81

Description

@Misterlae81

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})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions