python - Flask-Admin: Create child objects along with parent in the "create" form -
in flask/sqlalchemy application have sqlalchemy classes parent , child, interesting data each parent in children:
class parent(base): __tablename__ = 'parent' id = column(integer, primary_key=true) children = relationship(child) class child(base): __tablename__ = 'child' id = column(integer, primary_key=true) parent_id = column(integer, foreignkey('parent.id')) name = column(string) i want create parents in flask-admin ui, , when create them want able create child objects @ same time. when go "create" form in default modelview parent, can choose existing child objects menu, not create new ones.
for example, when creating each parent have text fields can type "names" of child objects, when flask-admin creates parent, creates child objects values in "name" columns.
is possible flask-admin? or if not, how customize flask-admin modelview it?
i think looking inline models.
you can use them in example with:
class parentmodelview(modelview): inline_models = (child, )
Comments
Post a Comment