title: Class Based Generic UpdateView inline
body: <p>I have the following models</p>
  
  <pre><code>class Cv(models.Model):
      name = models.CharField(_('name'), max_length=250)
      objective = models.CharField(_('objective'), max_length=250)
      slug = models.SlugField(editable=False)
  
  class Position(models.Model):
      cv = models.ForeignKey(Cv, verbose_name=_('cv'))
      start = models.DateField(_('start'))
      end = models.DateField(_('end'))
      name = models.CharField(_('name'), max_length=250)
      currently_employed = models.BooleanField(_('currently employed'))
      sector = models.IntegerField(_('sector'), choices=SECTOR_CHOICES)
      duties = models.TextField(_('duties'))
  </code></pre>
  
  <p>and the following forms:</p>
  
  <pre><code>class CvForm(ModelForm):
      class Meta:
          model = Cv
  
  class PositionForm(ModelForm):
      class Meta:
          model = Position
          widgets = {
              'start': DateInput(attrs={'class':'datepicker'}),
              'end': DateInput(attrs={'class':'datepicker'}),
          }
  
  PositionFormSet = inlineformset_factory(Cv, Position, form=PositionForm, extra=1)
  </code></pre>
  
  <p>I have created the following Generic CreateView which works great:</p>
  
  <pre><code>class CreateCvView(CreateView):
      model = Cv
      form_class = CvForm
      template_name = 'recruitment/cv/cv_detail.html'
  
      def get_success_url(self):
          self.success_url = '/'
          return self.success_url
  
      def get_context_data(self, **kwargs):
          context = super(CreateCvView, self).get_context_data(**kwargs)
          if self.request.POST:
              context['position_form'] = PositionFormSet(self.request.POST)
          else:
              context['position_form'] = PositionFormSet(instance=self.object)
          return context
  
      def form_valid(self, form):
          self.object = form.save(commit=False)
          self.object.slug = slugify(self.request.user)
          context = self.get_context_data()
          position_form = context['position_form']
          if position_form.is_valid():
              self.object = form.save()
              position_form.instance = self.object
              position_form.save()
              return HttpResponseRedirect(self.get_success_url())
          else:
              return self.render_to_response(self.get_context_data(form=form))
  </code></pre>
  
  <p>What I want to do is an UpdateView and so I copied the createview and passed it the slug as follows:</p>
  
  <pre><code>class EditCvView(UpdateView):
      model = Cv
      form_class = CvForm
      template_name = 'recruitment/cv/cv_detail.html'
  
      def get_success_url(self):
          self.success_url = '/'
          return self.success_url
  
      def get_context_data(self, **kwargs):
          context = super(EditCvView, self).get_context_data(**kwargs)
          if self.request.POST:
              context['position_form'] = PositionFormSet(self.request.POST)
          else:
              context['position_form'] = PositionFormSet(instance=self.object)
          return context
  
      def form_valid(self, form):
          self.object = form.save(commit=False)
          self.object.slug = slugify(self.request.user)
          context = self.get_context_data()
          position_form = context['position_form']
          if position_form.is_valid():
              self.object = form.save()
              position_form.instance = self.object
              position_form.save()
              return HttpResponseRedirect(self.get_success_url())
          else:
              return self.render_to_response(self.get_context_data(form=form))
  </code></pre>
  
  <p>It loads fine but when I post the form I get a 'list index out of range' error on PositionFormSet(self.request.POST) in get_context_data. Has anyone else had this problem?</p>