User<->Role

Report a typo

Create one to many relationship between Role model and User model(one role can be assigned to to many users).

Fill in the gaps with the relevant elements
#...
class Role(db.Model):    
    id = db.Column(db.Integer, primary_key = True)
    name = db.Column(db.String(20), unique = True)
    permissions = db.Column(db.Integer)
               
    
    #...

class User(db.Model):
    id = db.Column(db.Integer, primary_key = True) 
    username = db.Column(db.String(20), unique = True)
        
role_id = db.Column(db.Integer, db.ForeignKey("role.id"))roles = db.relationship("User", backref = "user)"users = db.relationship("User", backref = "role")user_id = db.Column(db.Integer, db.ForeignKey("user.id"))
___

Create a free account to access the full topic