How to tell flask-admin to use alternative representation when displaying Foreign Key Fields?

前端 未结 1 1783
礼貌的吻别
礼貌的吻别 2020-12-21 19:52

How can I tell flask-admin to use an alternative representation for Foreign Key Fields such as the following in this RoleUser link table?

相关标签:
1条回答
  • 2020-12-21 20:10

    The simplest way is to add __str__ methods (__unicode__ for Python 2) to your models.

    class Role(db.Model):
        # snip
        def __str__(self):
            return self.name
    
    0 讨论(0)
提交回复
热议问题