Registry / web-framework / django-json-widget

django-json-widget

JSON →
library2.1.1pypypi✓ verified 24d ago

Django JSON Widget provides an alternative, user-friendly widget for editing Django's JSONField, featuring syntax highlighting, automatic indentation, and validation. It leverages the JSONEditor JavaScript library to enhance the default Django form experience. The library is actively maintained, with frequent updates, and is currently at version 2.1.1.

pip install django-json-widget
INSTALL
IMPORT
SIG · DJANGO-JSON-WIDGET
D
django-json-widget
web-frameworkpythonv2.1.1
Install
1.5s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

JSONEditorWidget
from django_json_widget.widgets import JSONEditorWidget
from django_json_widget.widgets import JSONEditorWidget

To quickly integrate `django-json-widget` into your Django admin, add `django_json_widget` to your `INSTALLED_APPS` and then override the default widget for `JSONField` in your `admin.py` using `formfield_overrides`.

from django.contrib import admin from django.db import models from django_json_widget.widgets import JSONEditorWidget # models.py (example) class MyModel(models.Model): name = models.CharField(max_length=255) data = models.JSONField(default=dict) def __str__(self): return self.name # admin.py (example) from django.contrib import admin from .models import MyModel from django_json_widget.widgets import JSONEditorWidget @admin.register(MyModel) class MyModelAdmin(admin.ModelAdmin): list_display = ('name',) formfield_overrides = { models.JSONField: {'widget': JSONEditorWidget}, } # Alternatively, in a custom form: # from django import forms # from .models import MyModel # from django_json_widget.widgets import JSONEditorWidget # # class MyForm(forms.ModelForm): # class Meta: # model = MyModel # fields = ('name', 'data') # widgets = { # 'data': JSONEditorWidget, # }
Debug
Known issues
deprecatedThe `mode` argument for `JSONEditorWidget` is deprecated since version 0.2.0. Instead, specify the editor mode (e.g., 'tree', 'code', 'form') via the `options` dictionary, which accepts arguments directly from the underlying JSON Editor JavaScript library.
fix
Replace `JSONEditorWidget(mode='tree')` with `JSONEditorWidget(options={'mode': 'tree'})`.
affects: 0.2.0+
gotchaUsing inline scripts in the widget might conflict with Content Security Policies (CSP) if not properly configured, potentially leading to script blocking and functionality issues.
fix
Review and update your Django project's CSP to allow for the necessary inline scripts or consider alternative methods for integrating the widget if strict CSP is required.
affects: All versions
gotchaThere are reported issues with the widget not functioning correctly or rendering improperly when used within Django's `TabularInline` or when integrated with third-party admin themes like `Grappelli`.
fix
Test thoroughly when using with inlines or custom admin themes. For inlines, a custom form for the inline might be needed. For admin themes, custom CSS overrides may be required.
affects: All versions
breakingPrior to version 2.0.0, users experienced issues with Django 4.x due to missing sourcemaps and incorrect default paths for static files, leading to improper rendering or functionality.
fix
Upgrade to `django-json-widget` version 2.0.0 or higher to resolve static file and sourcemap issues with Django 4.x and newer.
affects: < 2.0.0
Upgrade
Version history
2.1.1latest on PyPI · released Dec 12, 2025
Audit
Dependencies
DjangorequiredThe widget is for Django's JSONField. Compatible with Django 3.2, 4.2, 5.0, 5.2 as per PyPI classifiers.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
django-json-widget — pip install django-json-widget · libregistry