﻿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
35110	in_bulk does not work with annotated fields, nor on foreign key	Cody Towstik	nobody	"in_bulk does some checks about the fields on the model using the class `_meta`.
It does not consider that fields can be annotated, or exist on another related model.

However, the code that does all the processing seems like it could handle both cases.

In both cases, you can make the field distinct.

{{{
class Person(models.Model):
    email = models.CharField()

class Customer(models.Model):
    person = models.ForeignKey(""Person"")

emails_to_process = [ ""a"", ""b"", ""c"" ]

# annotate case
Customer.objects.annotate(
    email_lower=Lower(""person__email"")
).distinct(
    ""email_lower""
).in_bulk(
    emails_to_process, fieldname=""email_lower""
)

# foreign key case
Customer.objects.distinct(""person__email"").in_bulk(emails_to_process, fieldname=""person__email)
}}}"	New feature	closed	Database layer (models, ORM)	dev	Normal	wontfix			Unreviewed	0	0	0	0	0	0
