Django JSON Editor

0.2.4 · active · verified Thu Apr 16

Django-JSONEditor is an online structured JSON input widget for Django that enhances the editing experience for various JSONField implementations. It integrates the core JSONEditor JavaScript library (from jsoneditoronline.org) into Django's admin interface and forms. The library is currently at version 0.2.4, with its last release in February 2023, and shows an active but somewhat dated approach to JSON editing within the Django ecosystem, with discussions around newer alternatives.

Common errors

Warnings

Install

Imports

Quickstart

To quickly integrate `django-jsoneditor` into your Django admin, add `jsoneditor` to your `INSTALLED_APPS` and then override the default widget for `JSONField` in your `admin.py` using `formfield_overrides`. Ensure you have an appropriate `JSONField` defined in your model, such as `django.db.models.JSONField` (for Django 3.1+ or with PostgreSQL) or a compatible third-party `JSONField`.

# settings.py
INSTALLED_APPS = [
    # ...
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'jsoneditor', # Add this line
    # ...
]

# models.py (Example using Django's native JSONField)
from django.db import models

class MyModel(models.Model):
    name = models.CharField(max_length=255)
    data = models.JSONField(default=dict)

    def __str__(self):
        return self.name

# admin.py
from django.contrib import admin
from django.db import models
from .models import MyModel
from jsoneditor.forms import JSONEditor

@admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
    formfield_overrides = {
        models.JSONField: {'widget': JSONEditor},
    }

view raw JSON →