summaryrefslogtreecommitdiff
path: root/tests/inline_formsets
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2013-11-20 21:34:29 +0100
committerClaude Paroz <claude@2xlibre.net>2013-11-20 21:37:35 +0100
commitd8fdee7db877e3a52a761bfcbeb3536ea219ec30 (patch)
treec0c9a7b7847f62cf48305395c85d72a3369e7776 /tests/inline_formsets
parent6f48ae0b0ffc42f63487f482d668507d986790df (diff)
[1.6.x] Fixed #21472 -- Fixed inline formsets display when parent pk is 0
Thanks agale031176@gmail.com for the report. Backport of fafb6cf049b from master.
Diffstat (limited to 'tests/inline_formsets')
-rw-r--r--tests/inline_formsets/tests.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/inline_formsets/tests.py b/tests/inline_formsets/tests.py
index ad8a666cb5..d2f79ae643 100644
--- a/tests/inline_formsets/tests.py
+++ b/tests/inline_formsets/tests.py
@@ -1,7 +1,7 @@
from __future__ import absolute_import, unicode_literals
from django.forms.models import inlineformset_factory
-from django.test import TestCase
+from django.test import TestCase, skipUnlessDBFeature
from django.utils import six
from .models import Poet, Poem, School, Parent, Child
@@ -157,3 +157,12 @@ class InlineFormsetFactoryTest(TestCase):
inlineformset_factory(
Parent, Child, exclude=('school',), fk_name='mother'
)
+
+ @skipUnlessDBFeature('allows_primary_key_0')
+ def test_zero_primary_key(self):
+ # Regression test for #21472
+ poet = Poet.objects.create(id=0, name='test')
+ poem = poet.poem_set.create(name='test poem')
+ PoemFormSet = inlineformset_factory(Poet, Poem, fields="__all__", extra=0)
+ formset = PoemFormSet(None, instance=poet)
+ self.assertEqual(len(formset.forms), 1)