Admin changelist turns QueryDict into dict

70 views
Skip to first unread message

Jonas von Poser

unread,
Nov 30, 2016, 4:17:49 PM11/30/16
to Django developers (Contributions to Django itself)
Hi everybody,

we've run into an interesting situation: we implemented a custom SimpleListFilter for the admin which presents the choices as a list of checkboxes. Pressing "submit" sends the list to the backend for filtering.

Unfortunately, this doesn't really work well and it took us a while to find out why: the ChangeList view request.GET (a QueryDict) into a dict.

This means, a query string in the form of ?q=123&state=1&state=2 simply loses all state values except the last one. It still works in principle but as soon as you e.g. click on a column heading to re-sort, the link breaks.

I checked the git log and traced this re-casting back to the "NEW ADMIN MERGE" in 2005. Does anyone know why this was done? Shouldn't we rather keep self.params as a QueryDict?

Thanks!

   Jonas

Florian Apolloner

unread,
Nov 30, 2016, 4:28:46 PM11/30/16
to Django developers (Contributions to Django itself)
Hi Jonas,

usually QueryDict are immutable, therefore the deletion of the params the line below does not work. Constructing a new mutable querydict should be fine though.

Cheers,
Florian

Adam Johnson

unread,
Nov 30, 2016, 4:31:19 PM11/30/16
to Django developers (Contributions to Django itself)
I suspect it was simply to make it easier to work with.

I'd suggest you create a ticket at https://code.djangoproject.com/newticket and then try making the change and seeing if Django's test suite still passes. All the information you should need is at https://docs.djangoproject.com/en/dev/internals/contributing/ .

Jonas von Poser

unread,
Dec 1, 2016, 5:06:48 AM12/1/16
to Django developers (Contributions to Django itself)
Thanks, I will!

Jonas
Reply all
Reply to author
Forward
0 new messages