Q:

Django + PostgreSQL: database representation of JSONField is changing

PostgreSQL 9.4.12
Django 1.10.7

With this minimal class :
from django.contrib.postgres.fields import JSONField

class Foobar(models.Model):
    extra_data = JSONField(blank=True, default="")

I run manage.py shell_plus :
In [2]: a=Foobar.objects.create()

In [3]: a.extra_data={}

In [4]: a.save()

In [6]: a.extra_data
Out[6]: {}

In [7]: a.refresh_from_db()

In [8]: a.extra_data
Out[8]: '{}'

In [9]: a.save()

In [10]: a.refresh_from_db()

In [11]: a.extra_data
Out[11]: '"{}"'

What could be the reason the JSONField value is quoted at each database save?

A:

Found it. This is a known incompatibility between django-jsonfield and django.contrib.postgres.fields.JSONField that cannot be used in same project.
cf https://bitbucket.org/schinckel/django-jsonfield/issues/57/cannot-use-in-the-same-project-as-djangos

