Skip to main content

Django-JSONEditor is an online structured JSON input widget for Django appropriate for various JSONField’s provided for Django.

Code of the javascript JSONEditor online editor has been got from the http://jsoneditoronline.org/ but slightly changed to avoid some issues.

See the latest versions of the javascript online JSON Editor here: https://github.com/josdejong/jsoneditor

Sample views:

https://raw.github.com/josdejong/jsoneditor/master/misc/jsoneditor.png

Don’t mismatch this repo with https://github.com/skyhood/django-jsoneditor

Installation

Latest version from the GIT repository:

pip install "git+git://github.com/nnseva/django-jsoneditor.git"

Stable version from the PyPi repository:

pip install django-jsoneditor

Note that you should use one of original JSONField packages to provide the JSONField itself.

Configuration

You should append jsoneditor into the INSTALLED_APPS of your settings.py file:

INSTALLED_APPS = (
    ...
    'jsoneditor',
    ...
)

You can use CDN repositories to get JSONEditor javascript code, or host it yourself, instead of the packaged one using the following two settings in your settings.py file:

JSON_EDITOR_JS = 'whatever-your-want.js'
JSON_EDITOR_CSS = 'whatever-your-want.css'

Just look to the http://cdnjs.com/libraries/jsoneditor and select the latest one, like:

JSON_EDITOR_JS = 'https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/4.2.1/jsoneditor.js'
JSON_EDITOR_CSS = 'https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/4.2.1/jsoneditor.css'

Use

You can use the JSONEditor widget for fields in selected Admin classes like

admin.py

from json_field import JSONField
from jsoneditor.forms import JSONEditor
class MyAdmin(admin.ModelAdmin):
    formfield_overrides = {
        JSONField:{ 'widget':JSONEditor },
    }

Or use the original JSONField implementation fixed by the package.

Right now there are three fixed implementations:

Use the fixed implementation instead of the original one.

models.py

from django.db import models

# from json_field import JSONField replaced by:
from jsoneditor.fields.django_json_field import JSONField
# Create your models here.

class TestModel(models.Model):
    my_field = JSONField()

You can access the underlying JSONEditor JS objects in your JavaScript via dictionary named jsonEditors. This dictionary’s keys are the IDs of the fields generated by this component in the form: "id"+[your form field name]+"_json_jsoneditor", e.g. id_template_parameters_json_jsoneditor. The values in the dictionary are the instances of the correspondent JSONEditor objects.

Release files for django-jsoneditor 0.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-jsoneditor 0.0.11
File Size Uploaded
django-jsoneditor-0.0.11.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-jsoneditor 0.0.11
File Interpreter ABI Platform
django_jsoneditor-0.0.11-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 62.8 kB

Release files / django-jsoneditor-0.0.11.tar.gz

Download URL django-jsoneditor-0.0.11.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8e642e9f8e368706782f886ede0f330700d4e7f3e603dda39f68a380f868d504
BLAKE2b-256 checksum
How to use checksums
3ec209893cfac799c62885bfbd17da700e3ca05637d08a23fcc9d873d12b3edf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_jsoneditor-0.0.11-py2.py3-none-any.whl

Download URL django_jsoneditor-0.0.11-py2.py3-none-any.whl
Size 59.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
68df3daa793b2e168922e45b6c925001eaeb7ac80156d01692396a4403c88cb9
BLAKE2b-256 checksum
How to use checksums
e7af5acca15ad5790dada276c20b6af34ddf09820c777c8390055bc221b03924
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page