django.contrib.postgres.fields.JSONField to django.db.models.JSONField Migration Path


A project I’m working has a use case for a model with a JSONField. I use Postgres for the db and was curious what the upgrade path looked like for the current Postgres specific JSON Field to the upcoming db-neutral JSONField in 3.1. It seems like it’d be a simple import statement swap, but wanted to check in case it’d be better off holding off until 3.1’s release to avoid any complicated migrations.


This is answered in the 3.1 release notes:

If your project uses django.contrib.postgres.fields.JSONField , plus the related form field and transforms, you should adjust to use the new fields, and generate and apply a database migration. For now, the old fields and transforms are left as a reference to the new ones and are deprecated as of this release.

You can also use django-jsonfield-backport instead of django.contrib.postgres but I don’t think there’s a huge advantage for that.

Thanks @adamchainz! I saw a blurb about 3.1 but hadn’t found the full release notes. Appreciate the link.