#29150: Pretty display of JSONField data in forms
--------------------------------------------+------------------------
Reporter: Andrew Wilson | Owner: (none)
Type: Uncategorized | Status: new
Component: contrib.postgres | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 1 |
--------------------------------------------+------------------------
I think `django.contrib.postgres.forms.jsonb.JSONField` should be modified
to display data in a more user-friendly way.
I am currently working around it with the following code, but I can't see
any reason this shouldn't be the default behaviour. I'm happy to open a
pull request if this is deemed useful.
{{{
import json
from django.contrib.postgres.forms.jsonb import InvalidJSONInput,
JSONField
class PrettyJSONField(JSONField):
def prepare_value(self, value):
if isinstance(value, InvalidJSONInput):
return value
return json.dumps(
value,
indent=4,
sort_keys=True,
separators=(',', ': '),
ensure_ascii=False,
)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29150>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/056.8ae1adad53a506e9ce11c71fd62953e0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.