#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.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/053.92bad723ba6a7f4579ae8472175274ca%40djangoproject.com.