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 :)
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']))]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With