0

This is my first time using Flask-Security, and I can't seem to successfully create a user.

Every time I try, I get a "User object has no attribute roles" error.

Here is the relevant code: https://gist.github.com/ianseyer/f08d3f47471588e79022

EDIT: Realized it might be because i didn't not have __tablename__ = 'roles', but that gives me this error:

sqlalchemy.exc.ArgumentError: Could not determine join condition between parent/child     tables on relationship User.role.  Specify a 'primaryjoin' expression.  If 'secondary' is     present, 'secondaryjoin' is needed as well.
codegeek
  • 32,236
  • 12
  • 63
  • 63
ian
  • 593
  • 2
  • 6
  • 16

1 Answers1

1

You've called it role. Change

role = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic'))

to

roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic'))
dirn
  • 19,454
  • 5
  • 69
  • 74