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:
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