Below I copied an example from the flask Megatutorial where users can follow other users and can be followed by other users. My question is how can I modify this, so that each user has the attribute 'connections', which returns all users you follow or who follow you? Basically removing the separation between users who follow you an users you follow.
Here is the table for that relationship
followers = db.Table('followers',
db.Column('follower_id', db.Integer, db.ForeignKey('user.id')),
db.Column('followed_id', db.Integer, db.ForeignKey('user.id'))
)
and here is the definition for the relationship
followed = db.relationship('User',
secondary=followers,
primaryjoin=(followers.c.follower_id == id),
secondaryjoin=(followers.c.followed_id == id),
backref=db.backref('followers', lazy='dynamic'),
lazy='dynamic')