Skip to main content

Compatability layer between django-jsonfield and Django's native JSONField

Project description

django-jsonfield-compat
=======================

![Travis Build Status](https://travis-ci.org/kbussell/django-jsonfield-compat.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/kbussell/django-jsonfield-compat/badge.svg?branch=master)](https://coveralls.io/github/kbussell/django-jsonfield-compat?branch=master)

Django 1.9 introduced first-class support for Postgresql's json type.

Not everyone uses Postgresql, nor has upgraded to 1.9 yet, so a mixed ecosystem exists.
Unfortunately, these two field types cannot be used together in the same project.

django-jsonfield-compat was created to be able to allow 3rd-party libraries to work in both worlds.

Requires Django >= 1.8

Installation
------------

`pip install django-jsonfield-compat`

Adjust all instances of importing `JSONField` and `JSONFormField` to `jsonfield_compat`'s definition (including all migration files!)

```
from jsonfield_compat import JSONField
from jsonfield_compat.forms import JSONFormField
```

Register your app from the AppConfig class's `ready()` function.

Example `apps.py`:

```
from __future__ import unicode_literals

from django.apps import AppConfig


class MyAppConfig(AppConfig):
name = 'myapp'
verbose_name = "My App"

def ready(self):
import jsonfield_compat
jsonfield_compat.register_app(self)
```


Now, when users of your application want to switch from using `django-jsonfield`'s implementation
to Django's native `JSONField`, they add the setting:

```
USE_NATIVE_JSONFIELD = True
```

And then run migrations to convert the app's DB tables to use the JSON column type.


License
-------

django-jsonfield-compat is licensed under the MIT license (see the `LICENSE` file for details).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-jsonfield-compat-0.4.4.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_jsonfield_compat-0.4.4-py2.py3-none-any.whl (6.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-jsonfield-compat-0.4.4.tar.gz.

File metadata

File hashes

Hashes for django-jsonfield-compat-0.4.4.tar.gz
Algorithm Hash digest
SHA256 0182d2e9db886abc2bf30958e4953f72b6f0e20336524755641bc3968899cd5b
MD5 5e401361e9ee08c3c30e80b379a72e5c
BLAKE2b-256 5cb3fd67cc1a09322e715322bfaf219c0693b5e0522659074ada49cf1c91d692

See more details on using hashes here.

File details

Details for the file django_jsonfield_compat-0.4.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_jsonfield_compat-0.4.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e2b1cd7dfef7633c8befb9c85fa764d344377512c8fdaf65ded4827392410a1d
MD5 440c5e2be5e778bc31891d820dbc3090
BLAKE2b-256 55e8ac686ec7499f0675fdcf2c9a5ad26a4bd02c23303f5bbd94028dd5e37b0b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page