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}
        }
    

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

untether-django-jsoneditor-0.1.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

untether_django_jsoneditor-0.1.0-py3-none-any.whl (577.2 kB view details)

Uploaded Python 3

File details

Details for the file untether-django-jsoneditor-0.1.0.tar.gz.

File metadata

  • Download URL: untether-django-jsoneditor-0.1.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for untether-django-jsoneditor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 01860023f93b5dda9bf5cfb4c9a4637aac78bd07e2e56eb1f9f19cfec20e9134
MD5 d1088515c21dfc866dcebe499e0c4504
BLAKE2b-256 9fad1cb8cb2e20264dc379acd6210f7f7ae8076ae54c3429567cfde3d09917cd

See more details on using hashes here.

File details

Details for the file untether_django_jsoneditor-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: untether_django_jsoneditor-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 577.2 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for untether_django_jsoneditor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5ce061dff00df29057cd2aad13f99991cac0cd7f9106a13ed47d3c7f0697cd0
MD5 12f693880c27c5075eec39614f237614
BLAKE2b-256 fd1f05f507324aa4f1ac4e7d5de6113c9d3a44866cece90b8b5ee406f7952355

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page