Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BinaryJSONField from playhouse.postgresql_ext not supported #33

Open
dev-zero opened this issue Feb 19, 2016 · 2 comments
Open

BinaryJSONField from playhouse.postgresql_ext not supported #33

dev-zero opened this issue Feb 19, 2016 · 2 comments

Comments

@dev-zero
Copy link

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?

dev-zero added a commit to dev-zero/wtf-peewee that referenced this issue Jul 21, 2016
dev-zero added a commit to dev-zero/wtf-peewee that referenced this issue Jul 22, 2016
@rudyryk
Copy link

rudyryk commented Jul 30, 2020

This is probably not an issue anymore? I'm using BinaryJSONField with Flask-Admin without such problems.

@fagci
Copy link

fagci commented Jan 11, 2021

Using playhouse for that, thanks, @rudyryk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants