def get_attribute(self, key, original=None):
"""
Get an attribute from the model.
:param key: The attribute to get
:type key: str
"""
in_attributes = key in self.__attributes
if in_attributes:
return self._get_attribute_value(key)
if key in self.__relations:
return self.__relations[key]
relation = original or super(Model, self).__getattribute__(key)
if relation:
return self._get_relationship_from_method(key, relation)
raise AttributeError(key)
评论列表
文章目录