[Django] #33204: Make MultiValueDict more consistent

9 views
Skip to first unread message

Django

unread,
Oct 16, 2021, 7:03:49 AM10/16/21
to django-...@googlegroups.com
#33204: Make MultiValueDict more consistent
----------------------------------------------+------------------------
Reporter: Yaroslav Pankovych | Owner: nobody
Type: New feature | Status: new
Component: Core (Other) | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
----------------------------------------------+------------------------
I was working with query parameters and found that `.pop()` and `.get()`
both have different logic.

I assume that `.pop()` should be the same as `.get()`, but the key should
get deleted afterward.

Here's an example:

{{{
In [1]: from django.utils.datastructures import MultiValueDict

In [2]: data = MultiValueDict({"name": ["Yaroslav", "Clara"], "age": [22,
32]})

In [3]: data.get("name")
Out[3]: 'Clara'

In [4]: data.pop("name")
Out[4]: ['Yaroslav', 'Clara']
}}}


As you can see, we've got a single item for `.get()`, and a list for
`.pop()`, which is confusing.

We should have all of that synced. `.get()` with `.getlist()`, and
`.pop()` with `.poplist()`.

Here's how it looks like after I've done some changes:

{{{
In [4]: data.pop("name")
Out[4]: 'Clara'
}}}


{{{
In [5]: data.poplist("name")
Out[5]: ['Yaroslav', 'Clara']
}}}


This is breaking change probably.

--
Ticket URL: <https://code.djangoproject.com/ticket/33204>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 16, 2021, 7:09:48 AM10/16/21
to django-...@googlegroups.com
#33204: Make MultiValueDict more consistent
------------------------------------+--------------------------------------

Reporter: Yaroslav Pankovych | Owner: nobody
Type: New feature | Status: new
Component: Core (Other) | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 1

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by Yaroslav Pankovych):

* cc: Yaroslav Pankovych (added)
* needs_docs: 0 => 1


Comment:

https://github.com/django/django/pull/14945

--
Ticket URL: <https://code.djangoproject.com/ticket/33204#comment:1>

Django

unread,
Oct 16, 2021, 8:18:59 AM10/16/21
to django-...@googlegroups.com
#33204: Make MultiValueDict more consistent
------------------------------------+--------------------------------------

Reporter: Yaroslav Pankovych | Owner: nobody
Type: New feature | Status: closed
Component: HTTP handling | Version: 3.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 1

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => wontfix
* component: Core (Other) => HTTP handling


Comment:

Thanks for the suggestion, however I don't think it's worth breaking
backwards compatibility. We need to reach a strong consensus on the
DevelopersMailingList before moving it forward. Please
[https://docs.djangoproject.com/en/stable/internals/contributing/triaging-
tickets/#closing-tickets follow the triaging guidelines with regards to
wontfix tickets] and take this to DevelopersMailingList.

--
Ticket URL: <https://code.djangoproject.com/ticket/33204#comment:2>

Reply all
Reply to author
Forward
0 new messages