Skip to content

Add support for Django 3.1 JSONField #7467

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

Merged
merged 1 commit into from
Sep 3, 2020
Merged

Add support for Django 3.1 JSONField #7467

merged 1 commit into from
Sep 3, 2020

Conversation

bespokebob
Copy link
Contributor

Description

Django 3.1 adds a new generic JSONField to replace the PostgreSQL-specific one. This adds support for the new field type, which should behave the same as the existing PostgreSQL field.

Fixes #7466

Copy link
Member

@rpkilby rpkilby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 lgtm

@rpkilby rpkilby added this to the 3.12 Release milestone Aug 5, 2020
@jairhenrique
Copy link
Contributor

@rpkilby is it possible to bump this fix before version 3.12?

@xordoquy
Copy link
Collaborator

xordoquy commented Aug 6, 2020

A few comments to remind us to remove the postgres_fields when DRF only supports Django 3.1+ would be nice.

@bespokebob
Copy link
Contributor Author

bespokebob commented Aug 6, 2020

A few comments to remind us to remove the postgres_fields when DRF only supports Django 3.1+ would be nice.

ArrayField and HStoreField will still be supported. I think the postgres JSONField will continue to work until Django 4.0.
The hasattr check could be removed after DRF only supports Django 3.1+, though.

@rpkilby
Copy link
Member

rpkilby commented Aug 6, 2020

I think we're fine merging as-is? We can remove the postgres-specific JSONField when 4.0 is released.

is it possible to bump this fix before version 3.12?

@jairhenrique Most likely no. DRF doesn't maintain "stable" branches, and master is currently targeting the upcoming 3.12 release. Per #7460, Tom specially created the 3.11.1 release to quickly add Django 3.1 compatibility.

@bespokebob
Copy link
Contributor Author

Oops, I didn't notice that the decoder change broke the tests. Should be fixed now.

Django 3.1 adds a new generic JSONField to replace the PostgreSQL-specific one. This adds support for the new field type, which should behave the same as the existing PostgreSQL field.

Django's new JSONField also includes support for a custom "decoder", so add support for that in the serializer field.
@bespokebob
Copy link
Contributor Author

@rsalmaso I think I've addressed all your comments, and I've cleaned up the branch history. Can you take another look?

@rsalmaso
Copy link
Contributor

👍 for me

@tomchristie
Copy link
Member

tomchristie commented Sep 3, 2020

Okay, right, let's get this one in now, and start looking at what we need to do to roll a 3.12 release.

Great work, thanks! 👍✨

@tomchristie tomchristie merged commit b3e0259 into encode:master Sep 3, 2020
@bespokebob bespokebob deleted the django31-json-field branch September 10, 2020 21:19
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
Django 3.1 adds a new generic JSONField to replace the PostgreSQL-specific one. This adds support for the new field type, which should behave the same as the existing PostgreSQL field.

Django's new JSONField also includes support for a custom "decoder", so add support for that in the serializer field.
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

Successfully merging this pull request may close these issues.

ModelSerializer Missing support for Django 3.1 JSONField
6 participants