ich möchte alle Trainings haben bei denen gilt Slot.taken==True.
Wieso kann ich das nicht folgendermaßen abfragen und erhalte eine Fehlermeldung?
Code: Alles auswählen
class Training(db.Model):
__tablename__ = 'trainings'
id = db.Column(db.Integer, primary_key=True, index=True)
(...)
#relationships
slot_id = db.Column(db.Integer, db.ForeignKey('slots.id')) #foreign key to the table name
class Slot(db.Model):
__tablename__ = 'slots'
id = db.Column(db.Integer, primary_key=True, index=True)
(...)
taken = db.Column(db.Boolean(), index=True)
#relationships
trainings = db.relationship('Training', backref='slots', uselist=False)
example = Training.query.filter_by(Training.slots.taken==True).first()
Fehler:
Code: Alles auswählen
AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with Training.slots has an attribute 'taken'