title: pass pk to CreateView form in django
body: <p>i'm new to django.</p>
  
  <p>I have a model that looks like this:</p>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>class Intervention(models.Model):
  subject = models.CharField(max_length=200)
  begin_date = models.DateField(default=datetime.datetime.today)
  end_date = models.DateField(default=datetime.datetime.today)
  description = models.TextField(blank=True)
  speaker = models.ForeignKey(CustomUser, on_delete=models.CASCADE)
  campus = models.ForeignKey(Campus, on_delete=models.CASCADE)
  
  class Meta:
      verbose_name = 'Intervention'
      verbose_name_plural = 'Interventions'
  
  def __str__(self):
      return self.subject
  
  class Evaluation(models.Model):
  interventions = models.ForeignKey(Intervention, on_delete=models.CASCADE)
  student_id = models.CharField(max_length=20)
  speaker_knowledge_mark = models.IntegerField(validators=[MaxValueValidator(20), MinValueValidator(0)])
  speaker_teaching_mark = models.IntegerField(validators=[MaxValueValidator(20), MinValueValidator(0)])
  speaker_answer_mark = models.IntegerField(validators=[MaxValueValidator(20), MinValueValidator(0)])
  slide_content_mark = models.IntegerField(validators=[MaxValueValidator(20), MinValueValidator(0)])
  slide_examples_mark = models.IntegerField(validators=[MaxValueValidator(20), MinValueValidator(0)])
  comment = models.TextField(blank=True)
  </code></pre>
  
  <p>The idea is when that the student enter the website on home page he have to choose the campus where he study then he is redirected to a page where he see only interventions of his campus then when he choose the intervention he get the detail of it :</p>
  
  <p><a href="https://i.stack.imgur.com/UTGMS.png" rel="nofollow noreferrer">Home page screen</a></p>
  
  <p><a href="https://i.stack.imgur.com/KYuRe.png" rel="nofollow noreferrer">Interventions page</a></p>
  
  <p><a href="https://i.stack.imgur.com/MEL3K.png" rel="nofollow noreferrer">Intervetion detail page</a></p>
  
  <p>Everything is working so far. Now on "intervention detail page" when the user click on "give mark" he is redirected to a page to create mark  (i use CreateView class-based) like below:</p>
  
  <p><a href="https://i.stack.imgur.com/Uh3Hy.png" rel="nofollow noreferrer">create mark</a></p>
  
  <p>Now my question is how can i replace  Modelchoicefield in the generated form by pk of the intervetion that student want to give a mark?</p>
  
  <p><strong>Views.py</strong></p>
  
  <pre><code>class CreateEvaluationView(CreateView):
  form_class = NewEvaluation
  template_name = 'mark.html'
  def home(request):
     campus = Campus.objects.all().order_by('-name')
  return render(request, 'home.html', {'campus': campus})
  
  def mark(request):
  if request.method == 'POST':
      campus = request.POST.get('campus')
      intervention = Intervention.objects.filter(campus=campus)
      return render(request, 'mark.html', {'intervention': intervention})
  
  def intervention_detail(request, pk):
  intervention_detail = get_object_or_404(Intervention, pk=pk)
  return render(request, 'intervention_detail.html', {'intervention_detail': intervention_detail})
  </code></pre>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>    path('', views.home, name='home'),
  path('mark/', views.mark, name='mark'),
  path('mark/&lt;int:pk&gt;/', views.intervention_detail, name='intervention_detail'),
  path('mark/create/', CreateEvaluationView.as_view(template_name="givemark.html"), name='newmark'),
  path('intervention/create/', login_required(CreateInterventionView.as_view(template_name="intervention_create.html")), name='create'),
  path('intervention/', login_required(ListInterventionView.as_view(template_name="intervention_list.html")), name='list'),
  </code></pre>
  
  <p>Thanks in advance for your help!
  Bast regards.</p>