summaryrefslogtreecommitdiff
path: root/tests/regressiontests/inline_formsets/tests.py
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-05-08 09:59:46 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-05-08 09:59:46 +0000
commit614d881450983fa3678761f68aaf188c38a5a228 (patch)
tree25dbc92bdbc85d057f226b695a2c0d0f699085a9 /tests/regressiontests/inline_formsets/tests.py
parenteaf8ec54d2f9aed4f66c1c596a8eef3bc85c879c (diff)
Fixed #10750: respect comment=False in inline formsets. Thanks, Koen Biermans.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10706 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/inline_formsets/tests.py')
-rw-r--r--tests/regressiontests/inline_formsets/tests.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/regressiontests/inline_formsets/tests.py b/tests/regressiontests/inline_formsets/tests.py
index 1d9a730479..aef6b3f10a 100644
--- a/tests/regressiontests/inline_formsets/tests.py
+++ b/tests/regressiontests/inline_formsets/tests.py
@@ -1,6 +1,6 @@
from django.test import TestCase
from django.forms.models import inlineformset_factory
-from regressiontests.inline_formsets.models import Poet, Poem
+from regressiontests.inline_formsets.models import Poet, Poem, School, Parent, Child
class DeletionTests(TestCase):
def test_deletion(self):
@@ -74,3 +74,28 @@ class DeletionTests(TestCase):
self.assertEqual(formset.is_valid(), True)
formset.save()
self.assertEqual(Poem.objects.count(), 0)
+
+ def test_save_new(self):
+ """
+ Make sure inlineformsets respect commit=False
+ regression for #10750
+ """
+ # exclude some required field from the forms
+ ChildFormSet = inlineformset_factory(School, Child, exclude=['father', 'mother'])
+ school = School.objects.create(name=u'test')
+ mother = Parent.objects.create(name=u'mother')
+ father = Parent.objects.create(name=u'father')
+ data = {
+ 'child_set-TOTAL_FORMS': u'1',
+ 'child_set-INITIAL_FORMS': u'0',
+ 'child_set-0-name': u'child',
+ }
+ formset = ChildFormSet(data, instance=school)
+ self.assertEqual(formset.is_valid(), True)
+ objects = formset.save(commit=False)
+ for obj in objects:
+ obj.mother = mother
+ obj.father = father
+ obj.save()
+ self.assertEqual(school.child_set.count(), 1)
+