summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorMadalin Popa <contact@madalinpopa.com>2024-06-08 14:57:27 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-06-14 14:10:19 +0200
commitdbd1a8bd41f827e5af2ca167bdcccfeeeecbd939 (patch)
treee6d66328a04514dc0ea03e2c055ae3306ad05b55 /django/forms
parent64443f555f362ddf0c9094f8531c3da72a753827 (diff)
[5.1.x] Fixed #35488 -- Fixed BaseModelFormSet.validate_unique() crash due to unhashable type.
Backport of d28626ecf8bd340084ed70ff2d88e8dbab001e2c from main.
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/models.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index 4cda4e534e..09be448984 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -23,6 +23,7 @@ from django.forms.widgets import (
SelectMultiple,
)
from django.utils.choices import BaseChoiceIterator
+from django.utils.hashable import make_hashable
from django.utils.text import capfirst, get_text_list
from django.utils.translation import gettext
from django.utils.translation import gettext_lazy as _
@@ -834,8 +835,8 @@ class BaseModelFormSet(BaseFormSet, AltersData):
(
d._get_pk_val()
if hasattr(d, "_get_pk_val")
- # Prevent "unhashable type: list" errors later on.
- else tuple(d) if isinstance(d, list) else d
+ # Prevent "unhashable type" errors later on.
+ else make_hashable(d)
)
for d in row_data
)