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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d80ffaab08b063125e23ab53337f13c7613076bb9b763a86b3cb2e7e3a087f0a |
|
MD5 | ef52d0009996036807cf6e11d5a5f041 |
|
BLAKE2b-256 | d44de001370353ec5504eac5402316948f93fc4e3da0ab849b0471845da136de |
Close
Hashes for django_jsoneditor_widget-1.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6b3e911fb3a4e4285cc68125437f8481734bb91954cc116e0965f7bd3bdf81a |
|
MD5 | bbbe1f5e383533b9bc0a83bd2de85913 |
|
BLAKE2b-256 | ed48c2025f6928aea9239a6dda69df60e898999e5643257908bd5b80fae4c7cc |