diff options
| author | afenoum <anja1catus@gmail.com> | 2026-03-15 14:18:59 +0300 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-03-25 09:23:10 -0400 |
| commit | 26f8929f16c514bd9967cd78d8dcd7760b82cc92 (patch) | |
| tree | 2a0cb990a4132967197087f23430cab2ce91bb3c /django | |
| parent | 386257b33eb2a925cecc1a12ba5e7dd694617186 (diff) | |
Fixed #36913 -- Optimized MultipleChoiceField.validate().
Diffstat (limited to 'django')
| -rw-r--r-- | django/forms/fields.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py index 6408be2f06..7f978aa03d 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -965,7 +965,8 @@ class MultipleChoiceField(ChoiceField): if self.required and not value: raise ValidationError(self.error_messages["required"], code="required") # Validate that each value in the value list is in self.choices. - for val in value: + # Use set() to avoid redundant validation. + for val in set(value): if not self.valid_value(val): raise ValidationError( self.error_messages["invalid_choice"], |
