Updates to JSON field don’t persist to DB

If you are using Postgres < 9.4 you can’t update JSON field directly. You need flag_modified function to report the change to SQLAlchemy:

from sqlalchemy.orm.attributes import flag_modified
model.data['key'] = 'New value'
flag_modified(model, "data")
session.add(model)
session.commit()

Leave a Comment