def filter_users_by_email(email):
 from .models import EmailAddress
 User = get_user_model()
 mails = EmailAddress.objects.filter(email__iexact=email)
 users = [e.user for e in mails.prefetch_related('user')]
 if app_settings.USER_MODEL_EMAIL_FIELD:
  q_dict = {(app_settings.USER_MODEL_EMAIL_FIELD + '__iexact'): email}
  users += list(User.objects.filter(**q_dict))
 return list(set(users))

def filter_users_by_email ( email ) : from . models import EmailAddress User = get_user_model ( ) mails = EmailAddress . objects . filter ( email__iexact = email ) users = [ e . user for e in mails . prefetch_related ( 'user' ) ] if app_settings . USER_MODEL_EMAIL_FIELD : q_dict = { ( app_settings . USER_MODEL_EMAIL_FIELD + '__iexact' ) : email } users += list ( User . objects . filter ( ** q_dict ) ) return list ( set ( users ) )
return list of users by email address typically one .