def get_user_by_email(email):
 try:
  return EmailAddress.objects.get(email__iexact=email).user
 except EmailAddress.DoesNotExist:
  try:
   User = get_user_model()
   return User.objects.get(email__iexact=email)
  except User.DoesNotExist:
   return None

def get_user_by_email ( email ) : try : return EmailAddress . objects . get ( email__iexact = email ) . user except EmailAddress . DoesNotExist : try : User = get_user_model ( ) return User . objects . get ( email__iexact = email ) except User . DoesNotExist : return None
retrieves auser by its email address .