Giter Site home page Giter Site logo

jsonstore's Introduction

Django JSONStore

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

jsonstore's People

Contributors

kmmbvnr avatar andrewyager avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.