def get_profile_from_user(user):
 for field in user._meta.get_fields():
  try:
   if hasattr(user, field.name):
    attribute = getattr(user, field.name)
    if (get_profile_model() == type(attribute)):
     return attribute
  except Exception:
   logger.exception('Error getting profile attribute from user.')
 logger.info('Could not find profile attribute.')
 return None

def get_profile_from_user ( user ) : for field in user . _meta . get_fields ( ) : try : if hasattr ( user , field . name ) : attribute = getattr ( user , field . name ) if ( get_profile_model ( ) == type ( attribute ) ) : return attribute except Exception : logger . exception ( 'Error getting profile attribute from user.' ) logger . info ( 'Could not find profile attribute.' ) return None
tries to get the profile according to the class configured on auth_profile_module .