﻿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
26305	Can't filter ChangeList by postgres-specific lookups	Ivan Tsouvarev	nobody	"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` in `get_filters` try to determine, should it use `DISTINCT` on `array_field`
- call to `lookup_needs_distinct` happens, which will try to find `len` lookup in `QUERY_TERMS` list, and unfortunately `QUERY_TERMS` doesn't have any `ArrayField` lookups
- `len` lookup will be counted as field, but of course, model has no such field, so whole thing will fail with `FieldDoesNotExist` exception
- `FieldDoesNotExist` will be catched and reraised as `IncorrectLookupParameters`
- `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)"	New feature	closed	contrib.admin	1.9	Normal	duplicate			Unreviewed	0	0	0	0	0	0
