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

1

1

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

Flask-Admin

Kunstlied answered 10/1, 2016 at 6:25 Comment(0)
R
6

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
Reconnaissance answered 10/1, 2016 at 14:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.