title: Flask-Admin set up default user roles when register
body: <p>I making a dashboard with <strong>Flask-Admin</strong> and using <strong>Flask-SQLAlchemy</strong> for my models, like this:</p>
  
  <pre><code>roles_users = db.Table(
      'roles_users',
      db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
      db.Column('role_id', db.Integer(), db.ForeignKey('role.id'))
  )
  
  class Role(db.Model, RoleMixin):
      __tablename__ = 'role'
      id = db.Column(db.Integer(), primary_key=True)
      name = db.Column(db.String(80), unique=True)
  
  class User(db.Model, UserMixin):
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String(255))
      roles = db.relationship('Role', secondary=roles_users,
                              backref=db.backref('users', lazy='dynamic'))
  </code></pre>
  
  <p>I want when user register with <strong>Flask-Admin</strong>, the default role for the user has set up to <strong>client</strong>.
  <a href="https://i.stack.imgur.com/XPh5y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XPh5y.png" alt="enter image description here"></a></p>
  
  <p>I have try something like this on <strong><code>roles</code></strong> column:</p>
  
  <pre><code>roles = db.relationship('Role', secondary=roles_users,
                       backref=db.backref('users', lazy='dynamic'),
                       default='client') # or default=3 (which is '3' is the client id in roles_user association table.
  </code></pre>
  
  <p>But I got this message:</p>
  
  <pre><code>TypeError: relationship() got an unexpected keyword argument 'default'
  </code></pre>
  
  <p>And I have also tried this <a href="https://stackoverflow.com/a/51845825/8070090">solution</a> 
  But now working for me.</p>
  
  <p>So, is it possible to set default role when user register..?</p>
  
  <p><strong>NOTE</strong>: In the other case, I also ask very similar with this question <a href="https://stackoverflow.com/questions/54404689/flask-sqlalchemy-set-relationship-default-value">here</a>, but there are in different case. There I want the role are set up when I making a new user by <strong>superuser</strong>, not when users register by their own.</p>