I have 3 models created with Flask-SQLalchemy: User, Role, UserRole
user.py:
class Role( ActiveRecord, db.Model ):
__tablename__ = \"roles\"
#
it's a little tough here because you are using some unknown base classes like "ActiveRecord" and such. However, it looks pretty much like that "secondary" argument is wrong:
class User( db.Model, ActiveRecord ):
__tablename__ = "users"
# Schema
id = db.Column( db.Integer, primary_key = True )
email = db.Column( db.String( 90 ), unique = True )
password = db.Column( db.String( 64 ) )
# Relations
roles = db.relationship( "Role", secondary = "UserRole", \
backref = db.backref( "users" ) )
secondary
needs to refer to a Table
object, not a mapped class, if by string name then it would be "user_roles"
:
roles = db.relationship( "Role", secondary = "user_roles", \
backref = db.backref( "users" ) )