Giter Site home page Giter Site logo

jsonstore's Introduction

Django JSONStore

IN ORDER TO REDUCE MAINTENANCE COST, THE PACKAGE FUNCTIONALITY HAS BEEN MOVED INTO THE django-viewflow

PLEASE, CONSIDE TO UPGRADE AND UPDATE IMPORTS:

$ pip install django-viewflow>=2.0.0b1
from viewflow import jsonstore

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.1 2023-01-16

Package deprication on favor of django-viewflow

jsonstore's People

Contributors

andrewyager avatar kmmbvnr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jsonstore's Issues

JSON field created out of thin air

While adding jsonstore to a project, the following problem occurred:

After adding a JSON field to a model to use with jsonstore, Django detected the model change and created the appropriate migration. However, it does not work, because the JSON field is always created on the table, even without a migration doing that. It appears as soon as the initial migration runs, even though it is not defined in the initial migration.

The behaviour would be ok if Django didn't want to create a new migration for the field, even though it is already on the table at the time when makemigrations runs.

Is there any reason for this behaviour? Until now, I failed to find out why the field is created, and also why Django seems to ignore it when creating migrations.

Environment: Python 3.8, Django 3.0, PostgreSQL.

imoprt error

In [1]:  from jsonstore import JSONField
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-ae905a6b640b> in <module>
----> 1 from jsonstore import JSONField

~\anaconda3\lib\site-packages\jsonstore\__init__.py in <module>
      1 from datetime import datetime
      2
----> 3 from jsonstore.rest import JSONStore
      4 from jsonstore.store import EntryManager
      5 from jsonstore.operators import *

~\anaconda3\lib\site-packages\jsonstore\rest.py in <module>
      1 import re
----> 2 from urllib import unquote
      3 from urlparse import urljoin
      4 from datetime import datetime
      5 from hashlib import sha1

ImportError: cannot import name 'unquote' from 'urllib' (C:\Users\lidaoran\anaconda3\lib\urllib\__init__.py)

Commercial Licensing?

I'm categorically unable to work with the AGPL under some circumstances (Not my choice, I don't work in legal), and so having a commercial license option similar to the viewflow/viewflow library "pro" option would be useful.

AGPL licence warning?

Unless I'm mistaken any project that uses this will also be under the AGPL - which is a pretty major fact for anyone using it to be aware of.

I nearly overlooked this as it's fairly unusual in Django world. It would have been very problematic as the rest of my code is MIT licensed.

Considering this is fairly out of the ordinary - would it be a good idea to put a much clearer warning higher up in the readme? Not everyone is a licence lawyer and many people will just think "oh cool. open source"

values_list returns full JSON field instead of just requested values

When using the QuerySet's values_list method to retrieve only a list containing the values of selected fields, and using jsonstore field, the resulting list gets the whole JSON field represented as a string instead of only the extracted single field.

Can we somehow hook into the API there and make values_list work for jsonstore fields?

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.