Skip to main content

Django form widget form JSONField

Project description

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
    
    
    @admin.register(Book)
    class BookModelAdmin(JSONFieldAdminMixin, admin.ModelAdmin):
        pass
    

Project details


Download files

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

Source Distribution

django-jsoneditor-widget-1.0.7.tar.gz (1.9 kB view hashes)

Uploaded Source

Built Distribution

django_jsoneditor_widget-1.0.7-py3-none-any.whl (180.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page