Question

I have simple user-roles models pair, each has __repr__ method:

class User:
    ...........
    def __repr__(self):
        return '<User "{}">'.format(self.username)

class Role:
    ...........
    def __repr__(self):
        return '<Role "{}">'.format(self.rolename)

When these models used in Flask-Admin select-box 'Roles' appeared for user, but it is empty because flask-admin renders text unescaped and it is hidden as unknown html tag:

<li class="select2-results-dept-0 select2-result select2-disabled">
    <div class="select2-result-label">
        <span class="select2-match"></span>
        <role: 'admin'=""></role:></div></li>  ####HERE####
...........

How to change text rendering options for models without changing my __repr___ or __unicode__ method (I prefer this notation)?

Was it helpful?

Solution

If you will disable js page will render right, so look like problem in JS plugin select2. I created issue for this in flask-admin: https://github.com/mrjoes/flask-admin/issues/244.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top