Flask Admin didn't show all fields

Posted by twoface88 on Stack Overflow See other posts from Stack Overflow or by twoface88
Published on 2012-11-25T03:55:24Z Indexed on 2012/11/25 5:03 UTC
Read the original article Hit count: 210

Filed under:
|
|

I have model like this:

class User(db.Model):
    __tablename__ = 'users'
    __table_args__ = {'mysql_engine' : 'InnoDB', 'mysql_charset' : 'utf8'}
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True)
    email = db.Column(db.String(120), unique=True)
    _password = db.Column('password', db.String(80))

    def __init__(self, username = None, email = None, password = None):
        self.username = username
        self.email = email
        self._set_password(password)

    def _set_password(self, password):
        self._password = generate_password_hash(password)

    def _get_password(self):
        return self._password

    def check_password(self, password):
        return check_password_hash(self._password, password)

    password = db.synonym("_password", descriptor=property(_get_password, _set_password))

    def __repr__(self):
        return '<User %r>' % self.username

I have ModelView:

class UserAdmin(sqlamodel.ModelView):
    searchable_columns = ('username', 'email')
    excluded_list_columns = ['password']
    list_columns = ('username', 'email')
    form_columns = ('username', 'email', 'password')

But no matter what i do, flask admin didn't show password field when i'm editing user info. Is there any way ? Even just to edit hash code.

UPDATE: https://github.com/mrjoes/flask-admin/issues/78

© Stack Overflow or respective owner

Related posts about python

Related posts about flask