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-widgetVerified import paths — ran on the pinned version, not inferred.
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`.
Replace `JSONEditorWidget(mode='tree')` with `JSONEditorWidget(options={'mode': 'tree'})`.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.
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.
Upgrade to `django-json-widget` version 2.0.0 or higher to resolve static file and sourcemap issues with Django 4.x and newer.