﻿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
29166	in lookup doesn't work with lists in a When clause	Matthew Pava	nobody	"I have an annotation that worked fine in Django 1.11, but I just discovered that it doesn't work with Django 2.0.  The error message reported:
`TypeError: unhashable type: 'list'`

I have an `Order` model that has a `status` and `status_date` field, and here's the query that worked in the past (simplified):

{{{
Order.objects.annotate(
    end_date=Case(
        When(
            status__in=[3, 2],
            then=Cast(F('status_date'), DateField())
        ),
        default=Value(timezone.now().date())
    )
)
}}}

Note the list used as the arg in the `__in` lookup.

My current workaround is to use `Q` objects with the `|` operator.
{{{
Order.objects.annotate(
    end_date=Case(
        When(
            Q(status=3) | Q(status=2),
            then=Cast(F('status_date'), DateField())
        ),
        default=Value(timezone.now().date())
    )
)
}}}

Others may not find that workaround as practical.
"	Bug	new	Database layer (models, ORM)	2.0	Normal		lookup in		Unreviewed	0	0	0	0	0	0
