Django form widget form JSONField
Project description
django-jsoneditor-widget
Django form widget form JSONField
Demo
It look like this.
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} }
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-jsoneditor-widget-1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 396028588fe59bd3681be058e2b33e67c826d860317732df422db05212a473f5 |
|
MD5 | 21b57de6cced7bf3f39f02ac0ad051dd |
|
BLAKE2b-256 | 2c2d8e30795a765815f5552b582b2db76f278d8afdaa6a17fbbd8616fdab8729 |
Close
Hashes for django_jsoneditor_widget-1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 853c67402bdf9d4df6e8018476fabb6c87e44c8d6f0419432778d15066ee433f |
|
MD5 | 1fe952cba6044a8fb30616e4c753722c |
|
BLAKE2b-256 | 36555baf15d8a8b9f4ec44d2cf40bfbaf300db3d79c878bc41f459ea9986fb9e |