Expose JSONField data as a virtual django model fields.
Project description
Expose Django JSONField data as virtual model fields
Use ModelForm and ModelAdmin as usual. Perform simple queries. Migrate to real table columns when needed without code change.
Suitable to store dumb business data, quick prototypes without DB migrations, and replace multi-table inheritance joins.
Use with caution! Replacing relational structures with JSON data should be mindfull architecture decision.
Works with any JSONField django.contrib.postgres, django-annoying, django-mysql, upcoming django Cross-db JSONField
Work in progress part of https://json-schema.org definitions are only supported.
Quick start
import jsonstore from django import forms from django.contrib import admin from django.db import models from .??. import JSONField class Employee(models.Model): data = JSONField(default={}) full_name = jsonstore.CharField(max_length=250) hire_date = jsonstore.DateField() salary = jsonstore.DecimalField(max_digits=10, decimal_places=2) class EmployeeForm(forms.ModelForm): class Meta: model = Employee fields = ['full_name', 'hire_date', 'salary'] @admin.register(Employee) class EmployeeAdmin(admin.ModelAdmin): list_display = ['full_name', 'hire_date'] fields = ['full_name', ('hire_date', 'salary')]
Demo
The demo shows how to handle multiple User types within single table with JSONField and Django-Polymodels proxies.
$ export DATABASE_URL=postgresql://viewflow:viewflow@localhost/viewflow $ export DJANGO_SETTINGS_MODULE=demo.settings $ tox python manage.py migrate $ tox python manage.py runserver
License
Django JSONStore is an Open Source project licensed under the terms of the AGPL license - The GNU Affero General Public License v3.0 with the Additional Permissions described in LICENSE_EXCEPTION
You can more read about AGPL at AGPL FAQ This package license scheme follows to GCC Runtime library licensing. If you use Linux already, probably this package license, should not bring anything new to your stack.
Latest changelog
0.5.0 2020-12-31
Support for Django 3.1 JSONField
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size django_jsonstore-0.5.0-py2-none-any.whl (7.9 kB) | File type Wheel | Python version py2 | Upload date | Hashes View |
Filename, size django-jsonstore-0.5.0.tar.gz (17.5 kB) | File type Source | Python version None | Upload date | Hashes View |
Hashes for django_jsonstore-0.5.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9630c1fb43ae9f8e32733c5cf7d4c3775ba6f08532f517c64025053352d72844 |
|
MD5 | 81d9136c9dfd4a1bdbe6e0ef5c2d4832 |
|
BLAKE2-256 | 79582c70b2c3485e7ea7613b69cbe272bd626d20e61b730b14239fae6aeb81c7 |