I am using flask and the Flask-Admin extension. I have two models (using sql alchemy):
Project has the attribute:
tasks = db.relationship('Task', backref=db.backref('project'))
And tasks are a self referential tree structure with the key column in Task:
children = db.relationship("Task",
# cascade deletions
cascade="all, delete-orphan",
# many to one + adjacency list - remote_side
# is required to reference the 'remote'
# column in the join condition.
backref=db.backref("parent", remote_side=id),
# children will be represented as a dictionary
# on the "title" attribute.
collection_class=attribute_mapped_collection('title'),
)
I want to have a list template from Flask-Admin that shows me all Projects. This is easily done with the extension and the standard list view. But now I want to add the CRUD Interface (Example: http://examples.flask-admin.org/sqla/simple/admin/userview/) for the tasks that should appear upon clicking each on a project.
I don't know what is the best way to reach this goal. I thought about including an iframe for the Task in each table cell of a project row. But this is somehow ugly. How can I render the CRUD interface for the tasks belonging to its project in the project list template?
I know that Flask-Admin is able to link the two tables together (over the foreign keys in the model), but the standard way is not what I want, since it needs at least one click from getting from the project crud interface to the task crud interface. What I want is to have the both crud interfaces loaded on the same page.
Looking at the documentation it looks like this is as simple as providing an inline-models
class property to your Project
model view:
class ProjectModelView(ModelView):
inline_models = (Task, )