diff --git a/django/forms/models.py b/django/forms/models.py
index a849436..6419fcb 100644
a
|
b
|
class BaseInlineFormSet(BaseModelFormSet):
|
859 | 859 | form.data[form.add_prefix(self.fk.name)] = None |
860 | 860 | |
861 | 861 | # Set the fk value here so that the form can do its validation. |
862 | | setattr(form.instance, self.fk.get_attname(), self.instance.pk) |
| 862 | fk_value = self.instance.pk |
| 863 | if self.fk.rel.field_name != self.fk.rel.to._meta.pk.name: |
| 864 | fk_value = getattr(self.instance, self.fk.rel.field_name) |
| 865 | fk_value = getattr(fk_value, 'pk', fk_value) |
| 866 | setattr(form.instance, self.fk.get_attname(), fk_value) |
863 | 867 | return form |