Opened 10 years ago
Closed 10 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 ChangeListinget_filterstry to determine, should it useDISTINCTonarray_field- call to
lookup_needs_distincthappens, which will try to findlenlookup inQUERY_TERMSlist, and unfortunatelyQUERY_TERMSdoesn't have anyArrayFieldlookups lenlookup will be counted as field, but of course, model has no such field, so whole thing will fail withFieldDoesNotExistexceptionFieldDoesNotExistwill be catched and reraised asIncorrectLookupParametersIncorrectLookupParameterswill be catched and results in?e=1redirect
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 , 10 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
| Type: | Uncategorized → New feature |
Duplicate of #26184