summaryrefslogtreecommitdiff
path: root/tests/inline_formsets/tests.py
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2026-06-05 12:10:10 +0200
committerGitHub <noreply@github.com>2026-06-05 12:10:10 +0200
commita2348c85fc6c20087935c74cd99340dd4ef2dcdc (patch)
treecac239b31e1866a2d0c4df5285857ada28a1f4e5 /tests/inline_formsets/tests.py
parent8c2d3dca633629effad17ccc98730234f740d03f (diff)
Fixed #37139 -- Fixed inlines crash on parent models with db_default on primary key.
Diffstat (limited to 'tests/inline_formsets/tests.py')
-rw-r--r--tests/inline_formsets/tests.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/inline_formsets/tests.py b/tests/inline_formsets/tests.py
index eaabc350b4..78456ec514 100644
--- a/tests/inline_formsets/tests.py
+++ b/tests/inline_formsets/tests.py
@@ -1,7 +1,7 @@
from django.forms.models import ModelForm, inlineformset_factory
from django.test import TestCase, skipUnlessDBFeature
-from .models import Child, Parent, Poem, Poet, School
+from .models import Child, ChildUUIDPk, Parent, ParentUUIDPk, Poem, Poet, School
class DeletionTests(TestCase):
@@ -113,6 +113,18 @@ class DeletionTests(TestCase):
obj.save()
self.assertEqual(school.child_set.count(), 1)
+ @skipUnlessDBFeature("supports_uuid4_function", "supports_expression_defaults")
+ def test_add_form_uuid_pk(self):
+ ChildFormSet = inlineformset_factory(ParentUUIDPk, ChildUUIDPk, fields=["name"])
+ data = {
+ "child_set-TOTAL_FORMS": "1",
+ "child_set-INITIAL_FORMS": "1",
+ "child_set-MAX_NUM_FORMS": "0",
+ "child_set-0-name": "child",
+ }
+ formset = ChildFormSet(data)
+ self.assertIs(formset.is_valid(), False)
+
class InlineFormsetFactoryTest(TestCase):
def test_inline_formset_factory(self):