I use flask peewee together with flask-admin and it works fine for some model classes, but I got one model, that it does not work on and gives me the following error:
AttributeError: 'GroupMember' object has no attribute '_data'
This is how the model looks:
class GroupMember(BaseModel):
group = ForeignKeyField(Group)
member = ForeignKeyField(Member)
class Meta:
primary_key = CompositeKey('group', 'member')
As this model consists of only foreign keys, I thought I would need to create a custom view that lists the columns explicitly, because by default flask-admin hides those columns.
I did so:
class MyModelView(ModelView):
column_list = ('group', 'member')
And initialized the view: admin.add_view(MyModelView(GroupMember))
This honestly changed nothing and I still get the same error. I found related questions that mentioned "backrefs" - what would that do and how would I do this? Or is this even the reason for my problem?
from Peewee and Flask-Admin: View with only foreign keys missing attribute '_data'
No comments:
Post a Comment