diff options
| author | Madalin Popa <contact@madalinpopa.com> | 2024-06-08 14:57:27 +0200 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-06-13 16:21:53 +0200 |
| commit | d28626ecf8bd340084ed70ff2d88e8dbab001e2c (patch) | |
| tree | 905bb6267123c052332a005bc32cbbc72085aaf7 /tests/model_formsets | |
| parent | 2a32b233822683c51e59722b7c9aa0789fc4ab1b (diff) | |
Fixed #35488 -- Fixed BaseModelFormSet.validate_unique() crash due to unhashable type.
Diffstat (limited to 'tests/model_formsets')
| -rw-r--r-- | tests/model_formsets/tests.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/model_formsets/tests.py b/tests/model_formsets/tests.py index f78772da56..e5c026cee6 100644 --- a/tests/model_formsets/tests.py +++ b/tests/model_formsets/tests.py @@ -1703,6 +1703,30 @@ class ModelFormsetTest(TestCase): [{}, {"__all__": ["Please correct the duplicate values below."]}, {}], ) + def test_inlineformset_with_jsonfield(self): + class BookForm(forms.ModelForm): + title = forms.JSONField() + + class Meta: + model = Book + fields = ("title",) + + BookFormSet = inlineformset_factory(Author, Book, form=BookForm) + data = { + "book_set-TOTAL_FORMS": "3", + "book_set-INITIAL_FORMS": "0", + "book_set-MAX_NUM_FORMS": "", + "book_set-0-title": {"test1": "test2"}, + "book_set-1-title": {"test1": "test2"}, + "book_set-2-title": {"test3": "test4"}, + } + author = Author.objects.create(name="test") + formset = BookFormSet(data, instance=author) + self.assertEqual( + formset.errors, + [{}, {"__all__": ["Please correct the duplicate values below."]}, {}], + ) + def test_model_formset_with_custom_pk(self): # a formset for a Model that has a custom primary key that still needs to be # added to the formset automatically |
