1

Suppose I have this parent model:

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'))

I know I can add column description of parent model (GoogleAccount) using column_descriptions, but how do modify child model column description? Such that for GoogleAccountAPI.client_secrets, I can add info saying, Click here to authenticate to Google ?

Not sure do I need to add child view for GoogleAcountApi

Thanks!

swdev
  • 4,997
  • 8
  • 64
  • 106

1 Answers1

2

Found it here, so this is what you do:

inline_models = [(models.GoogleAccountApi, dict(
    column_descriptions=dict(client_secret='Retoken here')
))]
Community
  • 1
  • 1
swdev
  • 4,997
  • 8
  • 64
  • 106