Skip to main content

django-jsoneditor-widget

Django form widget form JSONField

Demo

It look like this.

demo image

Install

  • Install: pip install django-jsoneditor-widget
  • Settings:
    INSTALLED_APPS = [
        # some apps ....
        'jsoneditor',
        # other apps ...
    ]
    

Create model

from django.db import models
from django.contrib.postgres.fields import JSONField


class Book(models.Model):
    name = models.CharField(max_length=150)
    information = JSONField()

    def __str__(self):
        return self.name

Admin site settings

  • Use ModelAdmin

    from django.contrib import admin
    
    from jsoneditor.admin import JSONFieldModelAdmin
    
    from .models import Book
    
    
    admin.site.register(Product, JSONFieldModelAdmin)
    
  • Use mixin

    from django.contrib import admin
    
    from jsoneditor.admin import JSONFieldAdminMixin
    
    from .models import Book
    
    
    @admin.register(Book)
    class BookModelAdmin(JSONFieldAdminMixin, admin.ModelAdmin):
        pass
    
  • Use custom widget to specify jsoneditor options

    from django.contrib import admin
    from django.contrib.postgres.fields import JSONField
    
    from jsoneditor.forms import JSONEditor
    
    from .models import Book
    
    
    class TextJSONEditor(JSONEditor):
        jsoneditor_options = {
            "mode": "text"
        }
    
    
    @admin.register(Book)
    class BookModelAdmin(admin.ModelAdmin):
        formfield_overrides = {
            JSONField: {"widget": TextJSONEditor}
        }
    

Release files for untether-django-jsoneditor 0.1.0

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

Source distribution (sdist)

Source distribution for untether-django-jsoneditor 0.1.0
File Size Uploaded
untether-django-jsoneditor-0.1.0.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for untether-django-jsoneditor 0.1.0
File Interpreter ABI Platform
untether_django_jsoneditor-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 580.3 kB

Release files / untether-django-jsoneditor-0.1.0.tar.gz

Download URL untether-django-jsoneditor-0.1.0.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
01860023f93b5dda9bf5cfb4c9a4637aac78bd07e2e56eb1f9f19cfec20e9134
BLAKE2b-256 checksum
How to use checksums
9fad1cb8cb2e20264dc379acd6210f7f7ae8076ae54c3429567cfde3d09917cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

Release files / untether_django_jsoneditor-0.1.0-py3-none-any.whl

Download URL untether_django_jsoneditor-0.1.0-py3-none-any.whl
Size 577.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f5ce061dff00df29057cd2aad13f99991cac0cd7f9106a13ed47d3c7f0697cd0
BLAKE2b-256 checksum
How to use checksums
fd1f05f507324aa4f1ac4e7d5de6113c9d3a44866cece90b8b5ee406f7952355
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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