def has_profile(user):
 profile_model = get_profile_model()
 try:
  profile = user.get_profile()
 except AttributeError:
  related_name = profile_model._meta.get_field('user').related_query_name()
  profile = getattr(user, related_name, None)
 except profile_model.DoesNotExist:
  profile = None
 return bool(profile)

def has_profile ( user ) : profile_model = get_profile_model ( ) try : profile = user . get_profile ( ) except AttributeError : related_name = profile_model . _meta . get_field ( 'user' ) . related_query_name ( ) profile = getattr ( user , related_name , None ) except profile_model . DoesNotExist : profile = None return bool ( profile )
test utility function to check if user has profile .