1
0
mirror of https://github.com/django/django.git synced 2025-10-25 06:36:07 +00:00

Fixed #10992: fixed a bug saving inlines with custom primary key fields. Thanks, Zain.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10777 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss
2009-05-14 02:23:53 +00:00
parent 690cb616ce
commit e508bfd27f
2 changed files with 69 additions and 64 deletions

View File

@@ -612,7 +612,12 @@ class BaseModelFormSet(BaseFormSet):
for form in self.initial_forms:
pk_name = self._pk_field.name
raw_pk_value = form._raw_value(pk_name)
pk_value = form.fields[pk_name].clean(raw_pk_value).pk
# clean() for different types of PK fields can sometimes return
# the model instance, and sometimes the PK. Handle either.
pk_value = form.fields[pk_name].clean(raw_pk_value)
pk_value = getattr(pk_value, 'pk', pk_value)
obj = existing_objects[pk_value]
if self.can_delete:
raw_delete_value = form._raw_value(DELETION_FIELD_NAME)