File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1683,12 +1683,18 @@ def get_value(self, dictionary):
16831683 # We override the default field access in order to support
16841684 # lists in HTML forms.
16851685 if html .is_html_input (dictionary ):
1686- # First, try to get the value using the plain field name with getlist
1686+ # First, try to get the value using the plain field name with getlist.
16871687 # This handles standard HTML form list submissions like:
16881688 # <select multiple name="field"><option value="a">...
1689- val = dictionary .getlist (self .field_name , [])
1690- if len (val ) > 0 :
1691- # Support QueryDict lists in HTML input.
1689+ try :
1690+ # Call getlist with a single argument to support duck-typed MultiDicts
1691+ # that do not accept a default parameter.
1692+ val = dictionary .getlist (self .field_name )
1693+ except (TypeError , KeyError , AttributeError ):
1694+ # Fall back to treating the value as not provided.
1695+ val = []
1696+ if val :
1697+ # Support QueryDict lists and other list-like results in HTML input.
16921698 return val
16931699 # For partial updates, avoid calling parse_html_list unless indexed keys are present.
16941700 # This reduces unnecessary parsing overhead for omitted list fields.
You can’t perform that action at this time.
0 commit comments