diff options
Diffstat (limited to 'django/forms/widgets.py')
| -rw-r--r-- | django/forms/widgets.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 1bcfeba288..82685a3fea 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -851,7 +851,11 @@ class Select(ChoiceWidget): if self.allow_multiple_selected: return use_required_attribute - first_choice = next(iter(self.choices), None) + first_choice = ( + self.choices.peek() + if hasattr(self.choices, "peek") + else next(iter(self.choices), None) + ) return ( use_required_attribute and first_choice is not None |
