Flask-admin 中如何把两个关联的Model在同一个View中显示在同一个list里?


例如这两个model

class A(Model):
    id = Column(Integer, primary_key=True)
    b = relationship('B', backref='a') 

class B(Model):
    id = Column(Integer, primary_key = True)
    a_id = Column(Interger, ForeignKey = "A.id")

class aAdmin(ModelView):
    column_list = ('id', 'b.id')

admin.add_view(aAdmin(A, db.session))

这样的话b.id并没有能够获取到值,那么应该如何操作呢?

python flask flask-admin

JolBall 10 years, 10 months ago

inline_models


 inline_models = [(B, dict(form_columns=['id', 'a_id']))]

御坂19209 answered 10 years, 10 months ago

Your Answer