JSON input widget for paper-admin
Project description
paper-jsoneditor
JSON input widget for paper-admin.
Compatibility
python
>= 3.6django
>= 3.1paper-admin
>= 4.1.0
Installation
Install the latest release with pip:
pip install paper-jsoneditor
Add paper_jsoneditor
to your INSTALLED_APPS in django's settings.py
:
INSTALLED_APPS = (
# other apps
"paper_jsoneditor",
)
Usage
from django.db import models
from django.utils.translation import gettext_lazy as _
from paper_jsoneditor.fields import JSONField
class SampleModel(models.Model):
data = JSONField(
_("JSON"),
blank=True
)
class Meta:
verbose_name = _("Sample")
Result:
Preserving JSON object keys order
By default, Django uses the jsonb
internal type for JSONField
(for PostgreSQL).
From the Postgres documentation:
<...> jsonb does not preserve white space, does not preserve the order of object keys, and does not keep duplicate object keys. If duplicate keys are specified in the input, only the last value is kept.
In general, most applications should prefer to store JSON data as jsonb, unless there are quite specialized needs, such as legacy assumptions about ordering of object keys.
If you really do need to preserve the key order, use OrderedJSONField
.
It uses the TEXT
type to store data:
from django.db import models
from django.utils.translation import gettext_lazy as _
from paper_jsoneditor.fields import OrderedJSONField
class SampleModel(models.Model):
data = OrderedJSONField(
_("JSON"),
blank=True
)
class Meta:
verbose_name = _("Sample")
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
Hashes for paper_jsoneditor-0.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11d6f5e4e6afb6805b96c8557927f96fa54a9c0743aa3754eb1147b90b1175f1 |
|
MD5 | 1301121d5499f0ffddb7253b4fc32dd0 |
|
BLAKE2b-256 | 0c620f26bb8ad6a7111c9fb29b9c580bc2b9b4fba835d5f6d070cf75eea64fab |