Skip to content

href in modelview #633

Answered by aminalaee
sheldygg asked this question in Q&A
Discussion options

You must be logged in to vote

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

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by aminalaee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants