when attempting to assign a role to a user, what is the trick to make it work with the username instead of the email?
The following works:
user_datastore.add_role_to_user('nunya@beezwax.com', 'site-admin')
this does not work:
user_datastore.add_role_to_user('admin', 'site-admin')
the error it gives is:
AttributeError: 'NoneType' object has no attribute 'roles'
my model looks like so:
roles_users = db.Table('users_to_roles',
db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(16), unique=True)
email = db.Column(db.String(256), unique=True)
password = db.Column(db.String(255))
active = db.Column(db.Boolean())
confirmed_at = db.Column(db.DateTime())
roles = db.relationship('Role', secondary=roles_users,
backref=db.backref('users', lazy='dynamic'))