=============================
django-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 django-json-widget::
pip install django-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/jmrivas86/django-json-widget",
"name": "django-json-widget",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "django-json-widget",
"author": "Jos\u00e9 Manuel Rivas",
"author_email": "jmrivas86@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/59/09/e3f70ed588e634d9de5d059347ff3445419fff42b7bff44241500aef2216/django-json-widget-2.0.1.tar.gz",
"platform": null,
"description": "=============================\ndjango-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 django-json-widget::\n\n pip install django-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.0.1",
"project_urls": {
"Homepage": "https://github.com/jmrivas86/django-json-widget"
},
"split_keywords": [
"django-json-widget"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5909e3f70ed588e634d9de5d059347ff3445419fff42b7bff44241500aef2216",
"md5": "cc864bac07dfc9eb780e0555574968e8",
"sha256": "adb4cab17fe5a04139037d7d84725369530ef35b912c3790d3a7b13f99351358"
},
"downloads": -1,
"filename": "django-json-widget-2.0.1.tar.gz",
"has_sig": false,
"md5_digest": "cc864bac07dfc9eb780e0555574968e8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 292949,
"upload_time": "2024-03-25T10:00:51",
"upload_time_iso_8601": "2024-03-25T10:00:51.698295Z",
"url": "https://files.pythonhosted.org/packages/59/09/e3f70ed588e634d9de5d059347ff3445419fff42b7bff44241500aef2216/django-json-widget-2.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-25 10:00:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jmrivas86",
"github_project": "django-json-widget",
"travis_ci": true,
"coveralls": true,
"github_actions": false,
"requirements": [
{
"name": "Django",
"specs": [
[
">=",
"5"
]
]
}
],
"tox": true,
"lcname": "django-json-widget"
}