I have been struggeling for a few days with this now and trying to see
if I maybe can get some help here. I'm using SQLAlchemy with Flask
This is what I have tried so far:
I got a user class defined like this:
association_table = db.Table('association',
db.Column('user_id', db.Integer, db.ForeignKey('
user.id')),
db.Column('friend_id', db.Integer, db.ForeignKey('
friend.id'))
)
class Friend(db.Model):
id = db.Column(db.Integer, primary_key=True)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(20), unique=True)
password = db.Column(db.String(30))
friends = db.relationship("Friend",
secondary=association_table)
Basically I want to have a relationship to other objects of class User
in the field User.friends
What am I doing wrong here?
Thanks,
Stefan