def get_profile_user_fieldname(profile_model=None, user_model=None):
 Profile = (profile_model or get_profile_model())
 User = (user_model or get_user_model())
 for field in Profile._meta.fields:
  if (field.rel and (field.rel.to == User)):
   return field.name
 raise ImproperlyConfigured((u'Value for ACCOUNTS_PROFILE_MODEL does not contain a ForeignKey field for auth.User: %s' % Profile.__name__))

def get_profile_user_fieldname ( profile_model = None , user_model = None ) : Profile = ( profile_model or get_profile_model ( ) ) User = ( user_model or get_user_model ( ) ) for field in Profile . _meta . fields : if ( field . rel and ( field . rel . to == User ) ) : return field . name raise ImproperlyConfigured ( ( u'Value for ACCOUNTS_PROFILE_MODEL does not contain a ForeignKey field for auth.User: %s' % Profile . __name__ ) )
returns the name of the first field on the profile model that points to the auth .