I have a big table "student", I want to split this table to sub-tables like:
student_101, student_102 ... student_200
I defined a dynamic model in model.py:
class StudentDynamic(DynamicBase):
__abstract__ = True
id = db.Column(db.BigInteger(), primary_key=True, autoincrement=True)
name = db.Column(db.String(250), nullable=True, comment=u"student name")
phone = db.Column(db.BigInteger(), nullable=False, unique=True)
class = db.Column(db.String(50), nullable=True, comment=u"class")
....
def __repr__(self):
return '<Role %r>' % self.__tablename__
def get_student_dynamic_table(suffix):
tablename = 'student_%s' % suffix # dynamic table name
class_name = 'Student_%s' % suffix # dynamic class name
Model = type(class_name, (StudentDynamic,), {
'__tablename__': tablename
})
return Model
Now, I want to add a view to flask-admin like other add-view, but I don't know how to add sub-tables in one view.
How can I merge these sub-tables to one view in flask-admin like one big table before?