You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to view a table containing a BinaryJSONField I get an error
AttributeError: There is not possible conversion for '<class 'playhouse.postgres_ext.BinaryJSONField'>'
I extended the CustomModelConvert as follows in my admin.py which permits display of the column:
from flask_admin.contrib.peewee.form import CustomModelConverter
from playhouse.postgres_ext import BinaryJSONField
from wtforms import fields
CustomModelConverter.defaults[BinaryJSONField] = fields.TextAreaField
When saving the field, wtforms converts the JSON into a string, meaning that it wraps it in an extra pair of " ", converting any JSON array or hash into a string:
db=> select * from table;
id | settings
----+----------------
1 | {"foo": "bar"}
(1 Zeile)
becomes
fdb=> select * from table;
id | settings
----+----------------
1 | "{'foo': 'bar'}"
(1 Zeile)
after simply clicking Save in the flask admin interface.
Any ideas?
The text was updated successfully, but these errors were encountered:
dev-zero
added a commit
to dev-zero/wtf-peewee
that referenced
this issue
Jul 21, 2016
When trying to view a table containing a
BinaryJSONField
I get an errorI extended the
CustomModelConvert
as follows in myadmin.py
which permits display of the column:When saving the field, wtforms converts the JSON into a string, meaning that it wraps it in an extra pair of
" "
, converting any JSON array or hash into a string:becomes
after simply clicking Save in the flask admin interface.
Any ideas?
The text was updated successfully, but these errors were encountered: