All Projects → laymonage → django-jsonfield-backport

laymonage / django-jsonfield-backport

Licence: BSD-3-Clause license
Backport of the cross-DB JSONField model and form fields from Django 3.1.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to django-jsonfield-backport

Evolutility Ui Jquery
Model-driven Web UI for CRUD using REST or localStorage.
Stars: ✭ 164 (+355.56%)
Mutual labels:  forms, models
react-forms-processor
A forms processor for React
Stars: ✭ 63 (+75%)
Mutual labels:  forms, fields
enform
Handle React forms with joy 🍿
Stars: ✭ 38 (+5.56%)
Mutual labels:  forms, fields
ember-validated-form-buffer
A validated form buffer that wraps Ember Data models for use in forms.
Stars: ✭ 46 (+27.78%)
Mutual labels:  forms
react-conversational-ui
🤖 React conversational UI
Stars: ✭ 51 (+41.67%)
Mutual labels:  forms
ember-validity-modifier
Ember Octane addon to add custom validity (form validation) to form fields
Stars: ✭ 28 (-22.22%)
Mutual labels:  forms
RDForm
Create and edit RDF data in a HTML form
Stars: ✭ 16 (-55.56%)
Mutual labels:  forms
insect
🛠 Highly customisable, minimalistic input x select field for React.
Stars: ✭ 33 (-8.33%)
Mutual labels:  forms
psyplot
Python package for interactive data visualization
Stars: ✭ 64 (+77.78%)
Mutual labels:  models
DynamicalBilliards.jl
An easy-to-use, modular, extendable and absurdly fast Julia package for dynamical billiards in two dimensions.
Stars: ✭ 97 (+169.44%)
Mutual labels:  models
mlx
Machine Learning eXchange (MLX). Data and AI Assets Catalog and Execution Engine
Stars: ✭ 132 (+266.67%)
Mutual labels:  models
platform
A collection of minimalistic, easy-to-use and fully customizable Angular components, directives and services
Stars: ✭ 17 (-52.78%)
Mutual labels:  forms
mui-form-fields
Material UI + Final Form Forms and Components
Stars: ✭ 15 (-58.33%)
Mutual labels:  forms
RapidFormBundle
Create Symfony forms at record speed using PHP 8 attributes!
Stars: ✭ 33 (-8.33%)
Mutual labels:  forms
final-form-arrays
Array Mutators for 🏁 Final Form
Stars: ✭ 64 (+77.78%)
Mutual labels:  forms
form-saver
A simple script that lets users save and reuse form data.
Stars: ✭ 67 (+86.11%)
Mutual labels:  forms
forms
A library to build declarative, composable, reactive user interfaces with WebSharper.
Stars: ✭ 12 (-66.67%)
Mutual labels:  forms
streaming-form-data
Streaming parser for multipart/form-data written in Cython
Stars: ✭ 112 (+211.11%)
Mutual labels:  forms
Formidable
The PHP pragmatic forms library
Stars: ✭ 116 (+222.22%)
Mutual labels:  forms
MagicForm
The easiest way to make complex forms with validations.
Stars: ✭ 31 (-13.89%)
Mutual labels:  forms

django-jsonfield-backport

https://img.shields.io/pypi/l/django-jsonfield-backport

Backport of the cross-DB JSONField model and form fields from Django 3.1.

from django.db import models
from django_jsonfield_backport.models import JSONField

class ContactInfo(models.Model):
    data = JSONField()

ContactInfo.objects.create(data={
    'name': 'John',
    'cities': ['London', 'Cambridge'],
    'pets': {'dogs': ['Rufus', 'Meg']},
})
ContactInfo.objects.filter(
    data__name='John',
    data__pets__has_key='dogs',
    data__cities__contains='London',
).delete()

Features

Most features of the JSONField model and form fields from Django 3.1 are supported.

  • MariaDB, MySQL, Oracle, PostgreSQL, and SQLite support.
  • JSONField lookups and transforms support.
  • Custom encoder and decoder support.

Due to limited access to Django's APIs, some features are not supported.

  • Introspection is not supported.
  • On MariaDB and Oracle, Casting to JSONField must be done using the included JSONCast class.

This package is fully compatible with the JSONField from Django 3.1. That means you just need to change your imports and edit your migrations when you finally upgrade to Django 3.1. If you leave them as they are, this package will use the built-in JSONField and system warnings will be raised.

Requirements

This package supports and is tested against the latest patch versions of:

  • Python: 3.5 (Django 2.2 only), 3.6, 3.7, 3.8, 3.9
  • Django: 2.2, 3.0, 3.1
  • MariaDB: 10.2, 10.3, 10.4, 10.5
  • MySQL: 5.7, 8.0
  • Oracle: 12.2+ (only tested against 12.2.0.1 SE)
  • PostgreSQL: 9.5, 10, 11, 12
  • SQLite: 3.9.0+ with the JSON1 extension

All database backends are tested with the latest versions of their drivers. SQLite is also tested on GitHub Actions' latest macOS and Windows virtual environments.

Installation

  1. Use pip or your preferred dependency management tool to install the package.

    $ pip install django-jsonfield-backport
  2. Add "django_jsonfield_backport" to INSTALLED_APPS in your settings.

    INSTALLED_APPS = [
        ...
        "django_jsonfield_backport",
    ]

Usage

To use the model and form fields, import JSONField from django_jsonfield_backport.models and django_jsonfield_backport.forms, respectively.

Model field example:

from django.db import models
from django_jsonfield_backport.models import JSONField

class ContactInfo(models.Model):
    data = JSONField()

Form field example:

from django import forms
from django_jsonfield_backport.forms import JSONField

class ContactForm(forms.Form):
    data = JSONField()

JSONCast, KeyTransform, and KeyTextTransform classes are also available from django_jsonfield_backport.models.

Documentation

Since this package is a backport, the official Django 3.1 docs for models.JSONField and forms.JSONField are mostly compatible with this package.

Rationale

As of the creation of this package, JSONField implementations exist in multiple packages on PyPI:

  • Django: Before Django 3.1, PostgreSQL-only JSONField exists in the contrib.postgres module.
  • jsonfield: 1.1k stars, cross-DB support with no extended querying capabilities.
  • django-annoying: 787 stars, has a TextField-based JSONField with no extended querying capabilities.
  • Django-MySQL: 364 stars, has a MariaDB/MySQL-only JSONField with extended querying capabilities (not entirely the same as in contrib.postgres).
  • django-jsonfallback: 26 stars, uses JSONField from contrib.postgres and Django-MySQL before falling back to TextField-based JSONField.
  • django-json-field: 116 stars, TextField-based JSONField with custom encoder and decoder support with no extended querying capabilities (unmaintained).
  • django-jsonfield: 21 stars, cross-DB support with no extended querying capabilities.
  • django-jsonfield-compat: 8 stars, compatibility layer for contrib.postgres JSONField and django-jsonfield.
  • oracle-json-field: 2 stars, Oracle-only JSONField with extended querying capabilities (not entirely the same as in contrib.postgres).

Along with other unmaintained packages such as dj-jsonfield, vlk-django-jsonfield, linaro-django-jsonfield, jsonfield2, django-jsonfield2, django-softmachine, django-simple-jsonfield, easy_jsonfield, and django-jsonbfield.

Why create another one?

Up until the new JSONField in Django 3.1, there had been no implementation of JSONField that supports all the database backends supported by Django with more or less the same functionalities as the contrib.postgres JSONField provides.

Django's release process does not backport new features to previous feature releases. However, the current LTS release is 2.2 which is still supported until April 2022. The next LTS release is Django 3.2 in April 2021 that happens to be the end of extended support for Django 3.1.

Some projects only use LTS releases of Django. There are also incompatibilities between Django 3.0 and 3.1. Therefore, using Django 3.1 may not be an option for some people at the moment.

Since JSONField seems to be in popular demand and that it works well as a standalone package, I decided to create a backport.

Besides, I'm the co-author of the new JSONField. ¯\_(ツ)_/¯

License

This package is licensed under the BSD 3-Clause License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].