title: How to include an object from another model in a generic Django CreateView?
body: <p>Ok so I am trying to include the corrosponding Comment in my createAnswer View currently the url of the createAnswer page includes the pk ok the right comment so i need to get the comment by the id in the url.<br>
   My generic CreateView looks like this: <br></p>
  
  <pre><code>class createAnswer(CreateView):
     model = Answer
     fields = ['content']
     def getComment(self, request):
      ???
  
  
     comment = getComment()
  
      def get_success_url(self):
         this_path = self.request.get_full_path()
         path_list = this_path.split('/')
         def get_comment_id(self):
             for i in range(len(path_list)):
                 if path_list[i].isdigit():
                     return path_list[i]
         return '/blogcontact/comment/'+ get_comment_id(self)
     def form_valid(self,form):
      this_path = self.request.get_full_path()
      path_list = this_path.split('/')
      def get_comment_id(self):
          for i in range(len(path_list)):
              if path_list[i].isdigit():
                  return path_list[i]
  
      form.instance.author = self.request.user
      form.instance.comment = Comment.objects.get(id=get_comment_id(self))
      return super().form_valid(form)
  </code></pre>
  
  <p><br>
  My Urls.py looks like this:</p>
  
  <pre><code>from django.urls import path
  from . import views
  from .views import createAnswer
  
  urlpatterns = [
     path('contact/comment/&lt;int:pk&gt;/newanswer', createAnswer.as_view(), 
     name='answer-create')
  ]&lt;br&gt;
  </code></pre>
  
  <p>I would like to save the Comment object in a variable so i Can use it in the html template like this {{comment}}</p>