0
一直在閱讀SQLAlchemy的文檔,我無法理解這一點。考慮以下設置:從子表中篩選結果
boardset_user_association_table = db.Table('boardset_user_association',
db.Column('user_id', db.Integer, db.ForeignKey('user.id')),
db.Column('boardset_id', db.Integer, db.ForeignKey('boardset.id'))
)
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))
boardSet = db.relationship('BoardSet', secondary=boardset_user_association_table, backref='user')
def __repr__(self):
return "<User('%s','%s')>" % (self.username, self.id)
class BoardSet(db.Model):
__tablename__ = 'boardset'
id = db.Column(db.Integer, primary_key=True)
created = db.Column(db.DateTime)
boards = db.relationship('Board', backref='boardset', lazy='dynamic')
def __repr__(self):
return "<BoardSet('%s','%s')>" % (self.id, self.created)
我從用戶對象項目的集合,但我無法對實際數據進行任何過濾等。我想,例如在某些情況下,從User.boardSet由值字段中創建
太感謝了之後..知道我錯過了什麼! – StefanE 2012-07-19 09:19:05