title: Why does FormView (CBV) based view not have a URL parameter in context?
body: <p>I have a class based view which needs to accept a Form submission. I am trying to auto-populate some of the form fields using the primary key within the URL path (e.g. /main/video/play/135). The class based view is based on FormView, the code I have makes the pk available in context if I use TemplateView, but that is not particularly good for handling forms.</p>
  
  <p>urls.py</p>
  
  <pre><code>app_name = 'main'
  urlpatterns = [
      #path('', views.index, name='index'),
      path('video/&lt;int:pk&gt;', views.VideoDetailView.as_view(), name='detail'),
      path('video/preview/&lt;int:pk&gt;', views.VideoPreview.as_view(), name='preview'),
      path('player', views.PlayerListView.as_view(), name='player_list'),
      path('video/play/&lt;int:pk&gt;/', views.VideoPlayView.as_view(), name='play'),
      path('', views.VideoListView.as_view(), name="video_list")
  ]
  </code></pre>
  
  <p>Relevant class from views.py:</p>
  
  <pre><code>class VideoPlayView(FormView):
  
      template_name = "main/video_play.html"
      form_class = VideoPlayForm
      initial = {}
      http_method_names = ['get', 'post']
  
      def get_initial(self, **kwargs):
          initial = super().get_initial()
          #initial['video'] = pk
          initial['watch_date'] = datetime.date.today()
          return initial
  
      def get_context_data(self, **kwargs):
          kc = kwargs.copy()
          context = super().get_context_data(**kwargs)
          video = Video.objects.get(context['pk'])
          context['video'] = video
          context['test'] = kc
          self.initial['video'] = video.pk
          context['viewers'] = Viewer.objects.all()
          context['players'] = Player.objects.filter(ready=True)
          return context
  
      def form_valid(self, form):
          return HttpResponse("Done")
  </code></pre>
  
  <p>I get a key error at the line: </p>
  
  <pre><code>video = Video.objects.get(context['pk'])
  </code></pre>
  
  <p>Viewing the debug info on the error page indicates that the context does not have the pk value stored within it.</p>
  
  <p>If I change the base class to TemplateView with a FormMixin I don't get this key error (but I do have problems POSTing the form data), so I know that the code is basically okay. My understanding is that the FormView class should populate context in the same way as the TemplateView class.</p>
  
  <p>Any idea why FormView behaves this way, and how can I get this working?</p>