Django Flat JSON Key/Value Widget
Project description
If you ever needed to store a flexible dictionary of keys and values in your django models, you may have felt the need of giving your users a widget to easily manipulate the data by adding or removing rows, instead of having to edit the raw JSON.
This package solves exactly that problem: it offers a widget to manipulate a flat JSON object made of simple keys and values.
Compatibility
Tested on python >= 3.8 and Django 3.2, 4.1 and 4.2.
It should work also on previous versions of Django.
Install stable version from pypi
Install from pypi:
pip install django-flat-json-widget
Usage
Add flat_json_widget to INSTALLED_APPS:
INSTALLED_APPS = [
# other apps...
"flat_json_widget",
]
Then load the widget where you need it, for example, here’s how to use it in the django admin site:
from django.contrib import admin
from django import forms
from .models import JsonDocument
from flat_json_widget.widgets import FlatJsonWidget
class JsonDocumentForm(forms.ModelForm):
class Meta:
widgets = {"content": FlatJsonWidget}
@admin.register(JsonDocument)
class JsonDocumentAdmin(admin.ModelAdmin):
list_display = ["name"]
form = JsonDocumentForm
Installing for development
Install your forked repo:
git clone git://github.com/<your_fork>/django-flat-json-widget
cd django-flat-json-widget/
python setup.py develop
Install development dependencies:
pip install -e .[test]
npm install -g jslint stylelint
Create database:
cd tests/
./manage.py migrate
./manage.py createsuperuser
Launch development server:
./manage.py runserver 0.0.0.0:8000
You can access the admin interface at http://127.0.0.1:8000/admin/.
Run tests with:
./runtests.py
Run quality assurance tests with:
./run-qa-checks
Contributing
Please refer to the OpenWISP contributing guidelines.
Changelog
See CHANGES.
License
See LICENSE.
Support
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
Built Distribution
Hashes for django_flat_json_widget-0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dca5a9798ff3b59387d9ef122be33783918b12c3af9c37fbdb1105c9698572d |
|
MD5 | addef371f0c670c64f9ca7cdb7f9571c |
|
BLAKE2b-256 | c2acad2c7f4e34f36af517f9dc0ca237fa2a8370ec0a7b1b46b2aafb798627ca |
Hashes for django_flat_json_widget-0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce578ed4fcaf1453d150cea3182f623bea2b97c58b4944aea727f301fc02ec6a |
|
MD5 | 5d055222c88d5158505619b3d4fd1320 |
|
BLAKE2b-256 | 51e5e892e314dff778a42612f6c18ba2afd89cf5be0289bd12cd7699c74799e3 |