In my application with SQLAlchemy i need to create many to many relationship between two contact object also sotre data for each of relatioship here is my Contact model
class Contact(db.Model): __tablename__ = 'contact' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Unicode(120), nullable=False, unique=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) to_contacts = db.relationship('Contact', secondary='ContactRelation', primaryjoin='id== ContactRelation.from_contact_id', secondaryjoin='id== ContactRelation.to_contact_id', backref='from_contacts') and my association class ContactRelation: class ContactRelation(db.Model): __tablename__ = 'contactrelation' id = db.Column(db.Integer, primary_key=True) from_contact_id = db.Column(db.Integer, db.ForeignKey('contact.id')) to_contact_id = db.Column(db.Integer, db.ForeignKey('contact.id')) relation_type = db.Column(db.String(100), nullable=True) every thing seems good but i have error : AttributeError: type object 'ContactRelation' has no attribute 'c' -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.