假设我有这个父模型:
class GoogleAccount(db.Model):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String, index=True)
class GoogleAccountApi(db.Model):
id = db.Column(db.Integer, primary_key=True)
client_secret = db.Column(db.String)
token = db.Column(db.String)
google_account_id = db.Column(db.Integer, db.ForeignKey(GoogleAccount.id))
google_account = db.relationship(GoogleAccount, backref=db.backref('google_account_id', cascade="all, delete-orphan", single_parent=True))
class GoogleAccountView(_ModelView):
inline_models = (models.GoogleAccountApi,)
column_descriptions = dict(
email='Halooo'
)
admin.add_view(GoogleAccountView(models.GoogleAccount, db.session, endpoint='google-account'))
我知道我可以使用 column_descriptions
添加父模型 (GoogleAccount) 的列描述,但如何修改子模型列描述?这样,对于 GoogleAccountAPI.client_secrets
,我可以添加信息:单击此处向 Google 进行身份验证
?
不确定是否需要为 GoogleAcountApi 添加 subview
谢谢!
最佳答案
找到了here ,所以这就是你要做的:
inline_models = [(models.GoogleAccountApi, dict(
column_descriptions=dict(client_secret='Retoken here')
))]
关于python - 如何定制 Flask-Admin 模块的内联模型 View /表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39267649/