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 untether-django-jsoneditor-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01860023f93b5dda9bf5cfb4c9a4637aac78bd07e2e56eb1f9f19cfec20e9134 |
|
MD5 | d1088515c21dfc866dcebe499e0c4504 |
|
BLAKE2b-256 | 9fad1cb8cb2e20264dc379acd6210f7f7ae8076ae54c3429567cfde3d09917cd |
Close
Hashes for untether_django_jsoneditor-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5ce061dff00df29057cd2aad13f99991cac0cd7f9106a13ed47d3c7f0697cd0 |
|
MD5 | 12f693880c27c5075eec39614f237614 |
|
BLAKE2b-256 | fd1f05f507324aa4f1ac4e7d5de6113c9d3a44866cece90b8b5ee406f7952355 |