从字段obj获取父表

2024-09-29 23:15:31 发布

您现在位置:Python中文网/ 问答频道 /正文

如何从字段对象获取父表类?Just.parent方法不能像预期的那样工作。g、 :

class SomeTable(Base): # Base have 'query' manager field
    somefield = Column(...)

def subroutine(field):
    table = field.parent # ????
    # should work exactly as
    # table = SomeTable
    table.query.filter(...)

subroutine(SomeTable.somefield)

Tags: 对象方法fieldbasehavetablemanagerquery

热门问题