﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35915	QueryDict __getitem__ returns an empty list when the value is an empty list	Nguyễn Hồng Quân	Joel Burns	"**Update:** forum post: https://forum.djangoproject.com/t/change-querydict-getitem-in-case-of-empty-list/36522


Though [https://docs.djangoproject.com/en/5.1/ref/request-response/#django.http.QueryDict.__getitem__ documentation] says that

   QueryDict.!__getitem!__(key)
   Returns the value for the given key. If the key has more than one value, it returns the last value.

It returns a list when the raw value is an empty list:

{{{#!python
>>> from django.http import QueryDict
>>> q = QueryDict('a=1', mutable=True)
>>> q['a']
'1'

>>> q.setlist('b', [])
>>> q['b']
[]
}}}

which surprises user and it even not mentioned in documentation.

Could we change this behavior? I know that we don't have a perfect solution, but returning `None` in this case is less bad than  empty list `[]`, because it is easier to annotate type.

- If returns `None`, we can annotate type as `str | None`.
- If returns `[]`, Python doesn't have an exact type for empty list, and `django-stubs` has to annotate as `str | list[object]` which is quite broader than the actual value (empty list)."	Cleanup/optimization	assigned	HTTP handling	5.1	Normal		querydict		Accepted	1	0	0	0	0	0
