GithubHelp home page GithubHelp logo

peterlitvak / django-jsoneditor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nnseva/django-jsoneditor

0.0 1.0 0.0 73 KB

Django JSONEditor input widget to provide javascript online JSON Editor

Python 5.88% JavaScript 87.96% CSS 6.16%

django-jsoneditor's Introduction

Django-JSONEditor

Django-JSONEditor is an online structured JSON input widget for Django appropriate for various JSONField's provided for Django.

Code of the javascript JSONEditor online editor has been got from the http://jsoneditoronline.org/ but slightly changed to avoid some issues.

See the latest versions of the javascript online JSON Editor here: https://github.com/josdejong/jsoneditor

Sample views:

json editor

Don't mismatch this repo with https://github.com/skyhood/django-jsoneditor

Installation

Latest version from the GIT repository::

pip install "git+git://github.com/nnseva/django-jsoneditor.git"

Stable version from the PyPi repository::

pip install django-jsoneditor

Note that you should use one of original JSONField packages to provide the JSONField itself.

Configuration

You should append jsoneditor into the INSTALLED_APPS of your settings.py file:

INSTALLED_APPS = (
    ...
    'jsoneditor',
    ...
)

You can use CDN repositories to get JSONEditor javascript code, or host it yourself, instead of the packaged one using the following two settings in your settings.py file:

JSON_EDITOR_JS = 'whatever-your-want.js'
JSON_EDITOR_CSS = 'whatever-your-want.css'

Just look to the http://cdnjs.com/libraries/jsoneditor and select the latest one, like:

JSON_EDITOR_JS = 'https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/4.2.1/jsoneditor.js'
JSON_EDITOR_CSS = 'https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/4.2.1/jsoneditor.css'

Use

You can use the JSONEditor widget for fields in selected Admin classes like:

admin.py:

from json_field import JSONField
from jsoneditor.forms import JSONEditor
class MyAdmin(admin.ModelAdmin):
    formfield_overrides = {
        JSONField:{ 'widget':JSONEditor },
    }

Or use the original JSONField implementation fixed by the package.

Right now there are two fixed implementations:

Use the fixed implementation instead of the original one

models.py:

from django.db import models

# from json_field import JSONField replaced by:
from jsoneditor.fields.django_json_field import JSONField
# Create your models here.

class TestModel(models.Model):
    my_field = JSONField()

You can access the underlying JSONEditor JS objects in your JavaScript via dictionary named jsonEditors. This dictionary's keys are the IDs of the fields generated by this component in the form: "id"+[your form field name]+"_json_jsoneditor", e.g. id_template_parameters_json_jsoneditor. The values in the dictionary are the instances of the correspondent JSONEditor objects.

Collecting bounties

I'm collecting small bounties to integrate django-jsoneditor with different JSONField implementations, see below:

Bountysource Bountysource Bountysource Bountysource Bountysource Bountysource Bountysource Bountysource Bountysource Bountysource Bountysource

Bountysource - Django Suit integration

Bountysource - Django Grappelli integration

django-jsoneditor's People

Contributors

nnseva avatar peterlitvak avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.