David Watson
David Watson

Reputation: 3432

How do I get flask-admin to allow inline editing PostgreSQL JSONB field using peewee model?

I have a flask app with a peewee model that is using flask-admin. I want to enable the editing of JSONB fields in the popup. I have set column_editable_list to the JSONB field in my model:

class AuthModelView(AuthMixinView, BaseModelView):
    column_editable_list = ('attrs',)

The JSONB field itself is declared:

attrs = BinaryJSONField()

I'm not sure what I have to do to get the JSON to show up in the editable popup instead of the [object Object].

enter image description here

I tried defining str, unicode, and repr methods on the model containing the JSONB attrs but that didn't work. Do I have to define a custom XEditableWidget?

It's worth noting that the edit form is able to display and edit the JSON:

enter image description here

I don't see why the inline form doesn't use the same field type mapping?

Upvotes: 2

Views: 1695

Answers (1)

pawl
pawl

Reputation: 354

This feature was added here: https://github.com/flask-admin/flask-admin/pull/1245

It's on the current master branch and should go out with the 1.4.0 release.

Upvotes: 2

Related Questions