**views.py**

```
def postdetail(request,pk): # Single Post view.

    post = Post.objects.get(id=pk)
    comment = post.comments.all()
    comment_count = comment.count()

    if request.user.is_authenticated:

        if request.method == 'POST':
            form = CommentForm(data=request.POST)
            content = request.POST['cMessage']

            if form.is_valid():
                print("Yes valid")
                form.instance.body = content
                new_comment = form.save(commit=False)
                print(new_comment)
                new_comment.post = post
                new_comment.user = request.user
                new_comment.save()
                return redirect('blog-home')
        else:

            form = CommentForm()

    context = {
        'comment_form': CommentForm,
        'post' : post,
        'comments': comment,
        'count': comment_count,
    }

    return render(request,'post/postdetail.html', context=context)

```

**models.py**

```
class Comment(models.Model):

    post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name='comments')
    user = models.ForeignKey(User,on_delete=models.CASCADE, related_name='comments')
    body = models.TextField()
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
    # active = models.BooleanField(default=True)

    class Meta:
        ordering = ('created',)

    def __str__(self):
        return f'Comment by {self.user} on {self.post}'

```

**forms.py** 

```
class CommentForm(forms.ModelForm):
    class Meta:
        model = Comment
        fields = ['body']

```

**template**

```
{% if request.user.is_authenticated %}
    <!-- respond -->
    <div class="respond">
        <h3>Leave a Comment</h3>
            <!-- form -->
                <form name="contactForm" id="contactForm" method="post" action="">
                {% csrf_token %}
                <fieldset>

                    <div class="message group">
                        <label  for="cMessage">Message <span class="required">*</span></label>
                        <textarea name="cMessage"  id="cMessage" rows="10" cols="50" ></textarea>
                    </div>

                    <button type="submit" class="submit">Submit</button>

                </fieldset>
                </form> <!-- Form End -->
    </div> 
{% endif %}

```

There is no error being displayed neither If I am adding a comment using the shell/through admin panel but if I am trying to add the comment dynamically through the form then the comment is not getting saved.
I have added only the form in the template.