Ticket #7938: 7938_custom_primary_key_formset_fix.1.diff
File 7938_custom_primary_key_formset_fix.1.diff, 824 bytes (added by , 16 years ago) |
---|
-
django/forms/models.py
378 378 379 379 def add_fields(self, form, index): 380 380 """Add a hidden field for the object's primary key.""" 381 self._pk_field_name = self.model._meta.pk.attname 382 form.fields[self._pk_field_name] = IntegerField(required=False, widget=HiddenInput) 381 if self.model._meta.has_auto_field: 382 self._pk_field_name = self.model._meta.pk.attname 383 form.fields[self._pk_field_name] = IntegerField(required=False, widget=HiddenInput) 383 384 super(BaseModelFormSet, self).add_fields(form, index) 384 385 385 386 def modelformset_factory(model, form=ModelForm, formfield_callback=lambda f: f.formfield(),