#36278: MultiValueDict should use sentinel for default values
-------------------------------------+-------------------------------------
Reporter: Peter Larsen - | Owner: (none)
Puzzel Solutions |
Type: New feature | Status: closed
Component: Utilities | Version: dev
Severity: Normal | Resolution: wontfix
Keywords: MultiValueDict | Triage Stage:
getlist default | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):
* component: Uncategorized => Utilities
* keywords: MultiValueDict sentinel => MultiValueDict getlist default
* resolution: => wontfix
* status: new => closed
* type: Uncategorized => New feature
* version: 5.1 => dev
Comment:
I don't think we should change this. The behavior is exactly as
[
https://docs.djangoproject.com/en/5.1/ref/request-
response/#django.http.QueryDict.getlist documented] for, `QueryDict`:
> Returns a list of the data with the requested key. Returns an empty list
if the key doesn’t exist and default is None. It’s guaranteed to return a
list unless the default value provided isn’t a list.
It makes sense to me that `getlist` should always return a list. The
intended usage is either to pass a non-`None` default or expect an empty
list as the result. Changing the semantics of default would be a new
feature, requiring not only a deprecation period but also community
consensus.
(Note that `MultiValueDict`, on its own, is not a documented nor public
data structure to reuse. It's the base structure for `QueryDict` and
that's the behavior I'm analyzing and prioritizing with this triage.)
--
Ticket URL: <
https://code.djangoproject.com/ticket/36278#comment:3>