Ticket #7888: 7888.diff

File 7888.diff, 821 bytes (added by Erwin, 16 years ago)
  • django/forms/models.py

     
    320320        if self.model._meta.has_auto_field:
    321321            self._pk_field_name = self.model._meta.pk.attname
    322322            form.fields[self._pk_field_name] = IntegerField(required=False, widget=HiddenInput)
     323        elif len(self.model._meta.parents) == 1:
     324            self._pk_field_name = self.model._meta.pk.attname
     325            form.fields[self._pk_field_name] = IntegerField(required=False, widget=HiddenInput,
     326                initial=self.instance.pk)
    323327        super(BaseModelFormSet, self).add_fields(form, index)
    324328
    325329def modelformset_factory(model, form=ModelForm, formfield_callback=lambda f: f.formfield(),
Back to Top