In factory boy it is possible to create a sqlalchemy object with a relationship to another table. There is a common recipe for Choosing from a populated table which is made for django, and I want to do this now for flask.
So I'd think that I have use this line.
user = factory.Iterator(User.query.all())
But of course it doesn't work. I get an error that there is no application context. It states in the documentation that the query wont be evaluated until the first call to to the Userfactory, however the error occurs when importing.
I want to have a factory that chooses the foreign key from an object that I already created. How can I do this in flask?