Opened 9 years ago
Closed 9 years ago
#26305 closed New feature (duplicate)
Can't filter ChangeList by postgres-specific lookups
Reported by: | Ivan Tsouvarev | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 1.9 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Say, I have model with ArrayField, and I want to limit choices to instances that have length of this array equal to 1:
localhost:8000/admin/app/model/?array_field__len=1
then admin will redirect me to
localhost:8000/admin/app/model/?e=1
Turns out, the following happens:
- admin try to compose relevant
ChangeList
ChangeList
inget_filters
try to determine, should it useDISTINCT
onarray_field
- call to
lookup_needs_distinct
happens, which will try to findlen
lookup inQUERY_TERMS
list, and unfortunatelyQUERY_TERMS
doesn't have anyArrayField
lookups len
lookup will be counted as field, but of course, model has no such field, so whole thing will fail withFieldDoesNotExist
exceptionFieldDoesNotExist
will be catched and reraised asIncorrectLookupParameters
IncorrectLookupParameters
will be catched and results in?e=1
redirect
In Django 1.8 it works fine, because lookup_needs_distinct
changed later in https://github.com/django/django/commit/d084176cc1273d5faf6f88eedb4c490e961f3a68
Also, I guess that chained lookups like Entry.objects.filter(pub_date__month__gt=6)
won't be working too (because lookup_needs_distinct
looks only on the last token in lookup)
Change History (1)
comment:1 by , 9 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Type: | Uncategorized → New feature |
Duplicate of #26184