问题
Hi there fellow Flask developers!
In Flask-admin, I currently try to implement inline model editing into my model view. On the model side, I have a simple tree structure that represents a set of content pages. Each node has several child nodes and also several content data models associated with it. The models are named ContentNode
and ContentData
.
If I use the inline_models
property on the node view class as described in the Docs here, it seems to work fine at first.
# AuthModelView is simply ModelView with user authentification
class ContentNodeModelView(AuthModelView):
...
inline_models = (models.ContentData, )
However, as soon as I try to pass properties to the inline form, using
inline_models = [(models.ContentData, dict(form_columns=['title', 'text']))]
the Flask server gives
AttributeError: 'ContentDataForm' object has no attribute 'id'
Am I missing something super obvious here? Is there maybe a mistake in the documentation because it sounds like maybe inline_models
expects a model but gets a dictionary?
I definitely checked that it's the same as in the docs.
Any help is greatly appreciated. Thanks :)
回答1:
You forgot to specify id, which uses for inline-form construction. Try to add 'id' attribute in:
inline_models = [(models.ContentData, dict(form_columns=['id', 'title', 'text']))]
来源:https://stackoverflow.com/questions/34313253/flask-admin-inline-modelling-passing-form-arguments-throws-attributeerror