Flask sql-alchemy many to many relationship append multi obj at once?

Viewed 1856

At first I define three table

registerations = db.Table()

class Student(db.Model):

class Class(db.Model):

I can use

student.classes.append(class1)
student.classes.append(class2)
student.classes.append(class3)
student.classes.append(class4)

to add info in the junction table, and it works well

but My problem is how can I add all classes to the student at once

student.classes.somemethod(class1, class2, class3, class4)

and is there a method that I can do this>> or I have to write a function by my own..

1 Answers
Related