title: How do display CommentForm in IndexView ? Django
body: <p>I have comments for each post and I want that users can just type their comments and submit them on the same page 'IndexView'</p>
  
  <p>here is my views.py</p>
  
  <pre><code>def IndexView(request):
  
      if request.user.is_authenticated():
          base_template_name = 'blog/base.html'
      else:
          base_template_name = 'blog/visitor.html'
  
      form = CommentForm()
      posts = Post.objects.all()
  
      return render(request, 'blog/index.html', {'form':form,'posts':posts,'base_template_name':base_template_name})
  
  
  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)
              comment.post = post
              comment.save()
              context = {'form':form}
              return render(request,'blog/index.html', context)
      else:
          form = CommentForm()
      return render(request, 'blog/index.html', {'form': form})
  </code></pre>
  
  <p>In <code>index.html</code> I put this (it displays the field put cannot submit it):</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" method="post" class="post-form"&gt;
      {% csrf_token %}
      {{ form.textc }}
      &lt;button type="submit" class="save btn btn-default"&gt;Send&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is my <code>CommentForm</code> in <code>forms.py</code></p>
  
  <pre><code>    class CommentForm(forms.ModelForm):
          class Meta:
              model = Comment
              fields = ('textc',)
  </code></pre>
  
  <p>And <code>urls.py</code> for <code>index</code> and <code>comment</code></p>
  
  <pre><code>    url(r'^post/(?P&lt;pk&gt;\d+)/comment/$', views.add_comment_to_post, name='add_comment_to_post'),
      url(r'^$', views.IndexView, name = 'index'),
  </code></pre>
  
  <p>[Edit]: Here is my models.py</p>
  
  <pre><code>class Post(models.Model):
      user = models.ForeignKey(User, null=True)
      title = models.CharField(max_length=200)
      image = models.CharField(max_length=1000, blank=True)
      #slug = models.SlugField(max_length=255, null=True, blank=True) 
      text = tinymce_models.HTMLField()
      created_date = models.DateTimeField(default=timezone.now)
      published_date = models.DateTimeField(blank=True, null=True)
  
      def publish(self):
          self.published_date = timezone.now()
          self.save()    
  
      def get_absolute_url (self):
          return reverse('blog:index')
  
      def __str__(self):
          return self.title
  
  class Comment(models.Model):
      post = models.ForeignKey('blog.Post', null=True,related_name='comments')
      user = models.ForeignKey(User, max_length=200, blank=True, null=True)
      textc = models.TextField(null=True,max_length=200)
      created_date = models.DateTimeField(default=timezone.now)
      approved_comment = models.BooleanField(default=False)
  </code></pre>
  
  <p>Thanks alot guys !</p>