adamchainz/django-jsonfield

Fix to work in parallel with django.contrib.postgres.JSONField

adamchainz opened this issue · 4 comments

See https://bitbucket.org/schinckel/django-jsonfield/issues/57/cannot-use-in-the-same-project-as-djangos

This issue looks complicated, there's a whole library by @kbussell to introduce that compatibility, https://github.com/kbussell/django-jsonfield-compat . The technique it uses should probably be merged in here!

What is the status of this bug? When can we expect a solution?

I believe it's because of this line https://github.com/adamchainz/django-jsonfield/blob/master/jsonfield/fields.py#L198

The registration is shared on the same database connection (see https://github.com/psycopg/psycopg2/blob/master/lib/_json.py#L93), so it'll interfere with contrib.postgres.

A fix I'd propose is to use select_format. I'm using it in my draft of JSONField for Django here: https://github.com/django/django/blob/f5674d94b2ce0447158d63e61ea011b235744446/django/db/models/fields/json.py#L76.

Might worth a look if @jakeatallyo (or anyone else) is looking for a quick fix.

@laymonage thank you for that comment. If you have some spare time it would be great if you could create a PR for that fix and test it alongside current and future Django JSONFields. You are the world expert now :)