summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2008-12-21 04:58:59 +0000
committerKaren Tracey <kmtracey@gmail.com>2008-12-21 04:58:59 +0000
commit73534cd9420a27eda6c725635fa1e4a3f1f9fbac (patch)
treee2772a0110db346d77b341def6554d2b7b406cd7 /django/forms
parent26554aa6b2444e1e3b1641bec773229d292c5587 (diff)
[1.0.X] Fixed #9865 -- Allow saving of new inline-edited objects with custom non-auto primary key fields that are not the foreign key to the parent object.
r9664 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9665 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/models.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index 81a7439331..d8c038faad 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -482,9 +482,14 @@ class BaseInlineFormSet(BaseModelFormSet):
return form
def save_new(self, form, commit=True):
- kwargs = {self.fk.get_attname(): self.instance.pk}
+ fk_attname = self.fk.get_attname()
+ kwargs = {fk_attname: self.instance.pk}
new_obj = self.model(**kwargs)
- return save_instance(form, new_obj, exclude=[self._pk_field.name], commit=commit)
+ if fk_attname == self._pk_field.attname:
+ exclude = [self._pk_field.name]
+ else:
+ exclude = []
+ return save_instance(form, new_obj, exclude=exclude, commit=commit)
def add_fields(self, form, index):
super(BaseInlineFormSet, self).add_fields(form, index)