diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 67e44829ff..1e67857c31 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -606,8 +606,8 @@ class ChoiceWidget(Widget): for subvalue, sublabel in choices: selected = ( - str(subvalue) in value and - (not has_selected or self.allow_multiple_selected) + (not has_selected or self.allow_multiple_selected) and + str(subvalue) in value ) has_selected |= selected subgroup.append(self.create_option(