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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c41436196e84caf54e2ad405bbd45ec92993e014ba15509773f271ed18048906 |
|
MD5 | f2f264eff4efb2664dfac9b6527f6079 |
|
BLAKE2b-256 | 395c7dbb24eb9898f7b57af836119062931d819ed89e2f7625ccc96694c53002 |
Close
Hashes for django_jsoneditor_widget-1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7db7c392f29235118196d099caf84c21a8735ff89f1ddd87406734d22c8d3357 |
|
MD5 | 43660618bce03994a59f2c7e8a4d1ac3 |
|
BLAKE2b-256 | eeefc55e00805fec7ee12788b415d526e775ad6c5ae2aaf7a49d05ac482411e7 |