Opened 6 years ago

Closed 6 years ago

#29581 closed Bug (wontfix)

MultiValueDict behaviour does not match dict behaviour for single values

Reported by: Piet van Agtmaal Owned by: nobody
Component: Utilities Version: 2.0
Severity: Normal Keywords: dict, MultiValueDict
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Description:
When using a MultiValueDict, retrieving the value for a key with only a single value yields unexpected and inconsistent results compared to a regular dictionary. See the code sample below.

>>> from django.utils.datastructures import MultiValueDict
>>> mvd = MultiValueDict()
>>> mvd['test'] = 1
>>> mvd['test']
1
>>> dict(mvd)['test']
[1]

Expected:
dict(mvd)['test'] yields 1, like mvd['test'] does

Actual:
dict(mvd)['test'] yields [1] instead

Change History (1)

comment:1 by Tim Graham, 6 years ago

Resolution: wontfix
Status: newclosed

I believe this is a duplicate of #12375. Even if the behavior could be changed (I'm not sure what the implementation would look like), backwards compatibility is probably more important. The resolution of the other ticket was to add the MultiValueDict.dict() method in 97f22f29699476d5bcbbf599a3dba22909f4ec85.

Note: See TracTickets for help on using tickets.
Back to Top