#27559: Admin changelist turns GET QueryDict into dict which may lose parameters
--------------------------------------+------------------------------------
Reporter: Jonas von Poser | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Ling-Xiao Yang):
* status: assigned => new
* owner: Ling-Xiao Yang => (none)
Comment:
I didn't find a good way of ensuring the backward compatibility, as this
turned out as a conceptual problem that has existed for a long time:
1. The admin filters are single-valued by definition
([https://github.com/django/django/blob/f0ef0c49e9284f262fbc63e8a497699ca4a248fe/django/contrib/admin/filters.py#L74-L75
example]) and this is semantically shown as `self.value()` in the code
example of
[https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_filter
related doc].
2. The `dict`-typed GET parameters are further
[https://github.com/django/django/blob/f0ef0c49e9284f262fbc63e8a497699ca4a248fe/django/contrib/admin/views/main.py#L114
passed from `ChangeList` view to filter classes], which would require a
change in both sides.
3. There is a `ChangeList.get_query_string` method that accepts an
additional `dict`-typed parameter (`new_params`) to allow modification of
GET parameters, see
[https://github.com/django/django/blob/f0ef0c49e9284f262fbc63e8a497699ca4a248fe/django/contrib/admin/filters.py#L74-L75
code]. And this method has been used in many places like
[https://github.com/django/django/blob/f0ef0c49e9284f262fbc63e8a497699ca4a248fe/django/contrib/admin/filters.py#L106
1],
[https://github.com/django/django/blob/f0ef0c49e9284f262fbc63e8a497699ca4a248fe/django/contrib/admin/templatetags/admin_list.py#L44
2],
[https://github.com/django/django/blob/f0ef0c49e9284f262fbc63e8a497699ca4a248fe/django/contrib/admin/templatetags/admin_list.py#L175
3] and so on. If we change every `dict` to `QueryDict`, it would be more
of a systematic change.
4. I considered an implicit OR connection of SQL queries in my last
comment, in order to restrict changes in `ChangeList` only, but this may
not be a good idea. First,
[https://tools.ietf.org/html/rfc3986#section-3.4 RFC 3986] has no
definition on the meaning of multi-valued GET parameter. Also, in the
other extension package django-filters, both OR and AND logic are allowed
in its `MultipleChoiceFilter`, see [http://django-
filter.readthedocs.io/en/develop/ref/filters.html#multiplechoicefilter its
doc]. So a multi-valued GET parameter such as `state=1&state=2` does not
necessarily mean an OR relationship in the filtering process.
I'm deassigning myself here. More people are welcomed to look at this
issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/27559#comment:4>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/063.ea0fee5674e3033d46b5273e9d304d13%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.