Why isn't SQLAlchemy translating this object generated by a FactoryBoy SubFactory into a foreign key?
问题 I'm using Flask and SQLAlchemy (via the Flask-SQLAlchemy extension) together with Factory_Boy. My GearItem model has a foreign key to GearCategory . Factory_Boy handles this through the SubFactory function that creates the object to be used as the foreign key in the original factory. Here are my model definitions: class GearCategory(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Text, unique=True, nullable=False) gear_items = db.relationship('GearItem', backref=