-
How i can create href in modelview? class UserModel(DefaultModelView, model=User):
column_formatters = {
User.username: lambda user, a: f"\n<a href='t.me/{user.username}'>{user.username}</a>\n" if user.username else ""
} I did this but I get a simple line =( |
Beta Was this translation helpful? Give feedback.
Answered by
aminalaee
Oct 2, 2023
Replies: 1 comment
-
This works: from markupsafe import Markup
class UserAdmin(ModelView, model=User):
column_formatters = {
"username": lambda user, u: Markup(f"<a href='https://t.me/{user.id}'>{user.id}</a>" if user.id else "#")
} Searching the similar solution for flask-admin usually gives the answer: https://stackoverflow.com/questions/37258668/flask-admin-how-to-change-formatting-of-columns-get-urls-to-display |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
aminalaee
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works:
Searching the similar solution for flask-admin usually gives the answer: https://stackoverflow.com/questions/37258668/flask-admin-how-to-change-formatting-of-columns-get-urls-to-display