Metadata-Version: 2.1
Name: django-admin-json-editor
Version: 0.2.2
Summary: A simple Django app to add JSON widget into Django Administration.
Home-page: https://github.com/abogushov/django-admin-json-editor
Author: Alexander Bogushov
Author-email: abogushov@gmail.com
License: MIT License
Description: # Django Administration JSON Editor
        
        [![Build Status](https://travis-ci.org/abogushov/django-admin-json-editor.svg?branch=master)](https://travis-ci.org/abogushov/django-admin-json-editor)
        
        ![Admin Json Editor](example/example.png)
        
        
        Application adds support for editing JSONField in Django Administration via https://github.com/json-editor/json-editor.
        
        ## Quick start
        
        Install application via pip:
        
        ```bash
        pip install django-admin-json-editor
        ```
        
        Add application to the INSTALLED_APPS settings:
        
        ```python
        INSTALLED_APPS = [
            ...
            'django_admin_json_editor',
            ...
        ]
        ```
        
        Define schema of json field:
        
        ```python
        DATA_SCHEMA = {
            'type': 'object',
            'title': 'Data',
            'properties': {
                'text': {
                    'title': 'Some text',
                    'type': 'string',
                    'format': 'textarea',
                },
                'status': {
                    'title': 'Status',
                    'type': 'boolean',
                },
            },
        }
        ```
        
        Use JSONEditorWidget to bind editor to the form field:
        
        ```python
        class JSONModelAdminForm(forms.ModelForm):
            class Meta:
                model = JSONModel
                fields = '__all__'
                widgets = {
                    'data': JSONEditorWidget(DATA_SCHEMA, collapsed=False),
                }
        ```
        
        ### Dynamic schema
        
        It is possible to build dynamic schema for widget:
        
        ```python
        def dynamic_schema(widget):
            return {
                'type': 'array',
                'title': 'tags',
                'items': {
                    'type': 'string',
                    'enum': [i for i in Tag.objects.values_list('name', flat=True)],
                }
            }
        ```
        
        ```python
        @admin.register(JSONModel)
        class JSONModelAdmin(admin.ModelAdmin):
            def get_form(self, request, obj=None, **kwargs):
                widget = JSONEditorWidget(dynamic_schema, False)
                form = super().get_form(request, obj, widgets={'tags': widget}, **kwargs)
                return form
        ```
        
        
Platform: UNKNOWN
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Description-Content-Type: text/markdown
