dj-json-widget


Namedj-json-widget JSON
Version 2.1.2 PyPI version JSON
download
home_pagehttps://github.com/erfan-rfmhr/dj-json-widget
SummaryDjango json widget is an alternative widget that makes it easy to edit the jsonfield field of django.
upload_time2025-02-19 07:00:27
maintainerNone
docs_urlNone
authorErfan Arefmehr
requires_pythonNone
licenseMIT
keywords dj-json-widget
VCS
bugtrack_url
requirements Django
Travis-CI
coveralls test coverage
            =============================
dj-json-widget
=============================

.. image:: https://badge.fury.io/py/django-json-widget.svg
    :target: https://badge.fury.io/py/django-json-widget

.. image:: https://travis-ci.org/jmrivas86/django-json-widget.svg?branch=master
    :target: https://travis-ci.org/jmrivas86/django-json-widget

.. image:: https://codecov.io/gh/jmrivas86/django-json-widget/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/jmrivas86/django-json-widget

An alternative widget that makes it easy to edit the new Django's field JSONField (PostgreSQL specific model fields)


Quickstart
----------

Install dj-json-widget::

    pip install dj-json-widget

Add it to your `INSTALLED_APPS`:

.. code-block:: python

    INSTALLED_APPS = (
        ...
        'django_json_widget',
        ...
    )

Add the widget in your admin.py:

.. code-block:: python

    from django.contrib import admin
    from django.db.models import JSONField
    from django_json_widget.widgets import JSONEditorWidget
    from .models import YourModel


    @admin.register(YourModel)
    class YourModelAdmin(admin.ModelAdmin):
        formfield_overrides = {
            JSONField: {'widget': JSONEditorWidget},
        }

You can also add the widget in your forms.py:

.. code-block:: python

    from django import forms
    from django_json_widget.widgets import JSONEditorWidget
    from .models import YourModel


    class YourForm(forms.ModelForm):
        class Meta:
            model = YourModel

            fields = ('jsonfield',)

            widgets = {
                'jsonfield': JSONEditorWidget
            }

Configuration
-------------

You can customize the JSONEditorWidget with the following options:

* **width**: Width of the editor as a string with CSS size units (px, em, % etc). Defaults to ``90%``.
* **height**: Height of the editor as a string CSS size units. Defaults to ``550px``.
* **options**: A dict of options accepted by the `JSON editor`_. Options that require functions (eg. onError) are not supported.
* **mode (deprecated)**: The default editor mode. This argument is redundant because it can be specified as a part of ``options``.  Preserved for backwards compatibility with version 0.2.0.
* **attrs**: HTML attributes to be applied to the wrapper element. See the `Django Widget documentation`_.

.. _json editor: https://github.com/josdejong/jsoneditor/blob/master/docs/api.md#configuration-options
.. _Django Widget documentation: https://docs.djangoproject.com/en/2.1/ref/forms/widgets/#django.forms.Widget.attrs


JSONEditorWidget widget
-----------------------

Before:

.. image:: https://raw.githubusercontent.com/jmrivas86/django-json-widget/master/imgs/jsonfield_0.png

After:

.. image:: https://raw.githubusercontent.com/jmrivas86/django-json-widget/master/imgs/jsonfield_1.png


Credits
-------

Tools used in rendering this package:

*  Cookiecutter_
*  `cookiecutter-djangopackage`_

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage




History
-------

0.1.0 (2017-05-10)
++++++++++++++++++

* First release on PyPI.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/erfan-rfmhr/dj-json-widget",
    "name": "dj-json-widget",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "dj-json-widget",
    "author": "Erfan Arefmehr",
    "author_email": "erfan.arefmehr@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b1/de/bf4353d0adf055467105b136a1726a21a5c75d1cef6c3abcbae71501b723/dj_json_widget-2.1.2.tar.gz",
    "platform": null,
    "description": "=============================\ndj-json-widget\n=============================\n\n.. image:: https://badge.fury.io/py/django-json-widget.svg\n    :target: https://badge.fury.io/py/django-json-widget\n\n.. image:: https://travis-ci.org/jmrivas86/django-json-widget.svg?branch=master\n    :target: https://travis-ci.org/jmrivas86/django-json-widget\n\n.. image:: https://codecov.io/gh/jmrivas86/django-json-widget/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/jmrivas86/django-json-widget\n\nAn alternative widget that makes it easy to edit the new Django's field JSONField (PostgreSQL specific model fields)\n\n\nQuickstart\n----------\n\nInstall dj-json-widget::\n\n    pip install dj-json-widget\n\nAdd it to your `INSTALLED_APPS`:\n\n.. code-block:: python\n\n    INSTALLED_APPS = (\n        ...\n        'django_json_widget',\n        ...\n    )\n\nAdd the widget in your admin.py:\n\n.. code-block:: python\n\n    from django.contrib import admin\n    from django.db.models import JSONField\n    from django_json_widget.widgets import JSONEditorWidget\n    from .models import YourModel\n\n\n    @admin.register(YourModel)\n    class YourModelAdmin(admin.ModelAdmin):\n        formfield_overrides = {\n            JSONField: {'widget': JSONEditorWidget},\n        }\n\nYou can also add the widget in your forms.py:\n\n.. code-block:: python\n\n    from django import forms\n    from django_json_widget.widgets import JSONEditorWidget\n    from .models import YourModel\n\n\n    class YourForm(forms.ModelForm):\n        class Meta:\n            model = YourModel\n\n            fields = ('jsonfield',)\n\n            widgets = {\n                'jsonfield': JSONEditorWidget\n            }\n\nConfiguration\n-------------\n\nYou can customize the JSONEditorWidget with the following options:\n\n* **width**: Width of the editor as a string with CSS size units (px, em, % etc). Defaults to ``90%``.\n* **height**: Height of the editor as a string CSS size units. Defaults to ``550px``.\n* **options**: A dict of options accepted by the `JSON editor`_. Options that require functions (eg. onError) are not supported.\n* **mode (deprecated)**: The default editor mode. This argument is redundant because it can be specified as a part of ``options``.  Preserved for backwards compatibility with version 0.2.0.\n* **attrs**: HTML attributes to be applied to the wrapper element. See the `Django Widget documentation`_.\n\n.. _json editor: https://github.com/josdejong/jsoneditor/blob/master/docs/api.md#configuration-options\n.. _Django Widget documentation: https://docs.djangoproject.com/en/2.1/ref/forms/widgets/#django.forms.Widget.attrs\n\n\nJSONEditorWidget widget\n-----------------------\n\nBefore:\n\n.. image:: https://raw.githubusercontent.com/jmrivas86/django-json-widget/master/imgs/jsonfield_0.png\n\nAfter:\n\n.. image:: https://raw.githubusercontent.com/jmrivas86/django-json-widget/master/imgs/jsonfield_1.png\n\n\nCredits\n-------\n\nTools used in rendering this package:\n\n*  Cookiecutter_\n*  `cookiecutter-djangopackage`_\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage\n\n\n\n\nHistory\n-------\n\n0.1.0 (2017-05-10)\n++++++++++++++++++\n\n* First release on PyPI.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Django json widget is an alternative widget that makes it easy to edit the jsonfield field of django.",
    "version": "2.1.2",
    "project_urls": {
        "Homepage": "https://github.com/erfan-rfmhr/dj-json-widget"
    },
    "split_keywords": [
        "dj-json-widget"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eebee094c6f80968e22e73e58feb2ac85a700570a2fe4285afb85b4f9b254885",
                "md5": "e9fff84e7240dffcd72157c200174195",
                "sha256": "6e8025147695c5649f1fe9aa9130d8a2dd9ae3a16c71b8fb9c09cfd2aa2bd7b8"
            },
            "downloads": -1,
            "filename": "dj_json_widget-2.1.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e9fff84e7240dffcd72157c200174195",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 292569,
            "upload_time": "2025-02-19T07:00:25",
            "upload_time_iso_8601": "2025-02-19T07:00:25.903236Z",
            "url": "https://files.pythonhosted.org/packages/ee/be/e094c6f80968e22e73e58feb2ac85a700570a2fe4285afb85b4f9b254885/dj_json_widget-2.1.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b1debf4353d0adf055467105b136a1726a21a5c75d1cef6c3abcbae71501b723",
                "md5": "a940f04f2f341560c09a9e5950561157",
                "sha256": "91c0a058c1815421424b123b89100719ac4e6e97d5f4540b93fcd29e5efeec0a"
            },
            "downloads": -1,
            "filename": "dj_json_widget-2.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "a940f04f2f341560c09a9e5950561157",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 292061,
            "upload_time": "2025-02-19T07:00:27",
            "upload_time_iso_8601": "2025-02-19T07:00:27.791077Z",
            "url": "https://files.pythonhosted.org/packages/b1/de/bf4353d0adf055467105b136a1726a21a5c75d1cef6c3abcbae71501b723/dj_json_widget-2.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-19 07:00:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "erfan-rfmhr",
    "github_project": "dj-json-widget",
    "travis_ci": true,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "Django",
            "specs": [
                [
                    ">=",
                    "5"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "dj-json-widget"
}
        
Elapsed time: 1.92209s