title: Previous form data being applied to Form for editing in django
body: <p>I have a way for users to edit comments they posted in Django but now Im trying to implement a feature where when users go to edit their comments the previous comment is displayed in the form.
  This way when a user goes to edit their comment it will show what they said previously in the form field.
  views.py</p>
  <pre><code>def update_comment(request, year, month, day, post,  comment_id = None ):
      post = get_object_or_404(Post , slug=post, status='cleared',publish__year=year,publish__month=month,publish__day=day)
      comments = post.comments.filter(active=True)
      comment = Comment.objects.get(id=comment_id)
      user = request.user
      comment_form = CommentForm(request.POST, instance=Comment.objects.get(id=comment_id))
      if (comment.name != user):
          raise PermissionDenied
      if request.method == 'POST':
          comment_form = CommentForm(request.POST, instance=Comment.objects.get(id=comment_id))
          if comment_form.is_valid():
              comment_form.instance.post = post
              comment_form.instance.name = request.user
              comment_form.save()
              return HttpResponseRedirect( post.get_absolute_url() )
      else:
          comment_form = CommentForm()
          return render(request,'posts/update_comment.html', {'post':post , 'comments': comments,'comment_form': comment_form, 'comment_id':comment_id })
  </code></pre>
  <p>urls.py</p>
  <pre><code>from . import views
  from django.urls import path, include, re_path
  from django.contrib.auth import views as auth_views
  from .views import PostListView, PostCreateView,PostUpdateView
  app_name = 'posts'
  urlpatterns = [
      path('', views.PostListView.as_view(), name='post_list'),
      #path('&lt;int:year&gt;/&lt;int:month&gt;/&lt;int:day&gt;/&lt;slug:post&gt;/',views.PostDetailView.as_view(),name='post_detail'),
      path('&lt;int:year&gt;/&lt;int:month&gt;/&lt;int:day&gt;/&lt;slug:post&gt;/',views.post_detail,name='post_detail'),
      path('post/new/',PostCreateView.as_view(), name='post-create'),
      path('&lt;int:year&gt;/&lt;int:month&gt;/&lt;int:day&gt;/&lt;slug:post&gt;/update/',PostUpdateView.as_view(), name='post-update'),
      path('&lt;int:year&gt;/&lt;int:month&gt;/&lt;int:day&gt;/&lt;slug:post&gt;/&lt;comment_id&gt;/',views.update_comment, name='update_comment'),
  ]
  </code></pre>
  <p>update_comment.html</p>
  <pre><code>{% extends &quot;Main/Base.html&quot; %}
  {% block content %}
  &lt;form method=&quot;POST&quot; action=&quot;{% url 'posts:update_comment' post.publish.year post.publish.month post.publish.day post.slug comment_id %}&quot;&gt;
  {{ comment_form.as_p }}
  {% csrf_token %}
  &lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;Update comment&quot;&gt;&lt;/p&gt;
  &lt;/form&gt;
  {% endblock %}
  </code></pre>
  <p>Thank you for any help in advance</p>