How to create communication many-to-one in SQLAlchemy?

There are two interrelated models
class ImageGroup(db.Model):
 __tablename__ = 'imagegroup'
 id = db.Column(db.Integer, primary_key=True)
 timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)

class Images(db.Model):
 id = db.Column(db.Integer, primary_key=True)
 img_filename = db.Column(db.String())
 counter = db.Column(db.Integer(), default=0)
 img_data = db.Column(db.String(264), unique=False)
 creation_date = db.Column(db.DateTime,
 imagegroup_id = db.Column(db.Integer, db.ForeignKey(''), nullable=False)
 imagegroup = db.relationship('Images', backref='images', lazy=True)

I need to do anything when you run the function upload_images formed a single instance ImageGroup and assigns all instances of Images from the loop.
result_img = job.result
 imagegroup = ImageGroup()
 for i in result_img:
 info = job.result[i]
 filename = (info['name'])
 count = info["count"]
 img_data = info['path']
 new_file = Images(img_filename=filename, counter=count, img_data=img_data, imagegroup_id=imagegroup)
 session['result'] = result_img

Instead imagegroup_id=imagegroup tried imagegroup=imagegroup but results in the error

"specify a 'primaryjoin' expression." % self.prop
sqlalchemy.exc.NoForeignKeysError: Could not determine join condition between parent/child tables on relationship Images.imagegroup - there are no foreign keys linking these tables. Ensure that referencing columns are associated with a ForeignKey or ForeignKeyConstraint, or specify a 'primaryjoin' expression.

Tell me how to make such relationship?
March 19th 20 at 08:40
0 answer

Find more questions by tags SQLAlchemy