def get_related_model_from_attribute(attribute):
 if isinstance(attribute, AssociationProxy):
  return attribute.remote_attr.mapper.class_
 return attribute.property.mapper.class_

def get_related_model_from_attribute ( attribute ) : if isinstance ( attribute , AssociationProxy ) : return attribute . remote_attr . mapper . class_ return attribute . property . mapper . class_
gets the class of the model related to the given attribute via the given name .