[Django] #29150: Pretty display of JSONField data in forms

2 views
Skip to first unread message

Django

unread,
Feb 21, 2018, 11:36:07 PM2/21/18
to django-...@googlegroups.com
#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.

Django

unread,
Feb 21, 2018, 11:36:26 PM2/21/18
to django-...@googlegroups.com
#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 | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
----------------------------------+--------------------------------------
Changes (by Andrew Wilson):

* Attachment "before.png" added.

Django

unread,
Feb 21, 2018, 11:36:41 PM2/21/18
to django-...@googlegroups.com
#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 | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
----------------------------------+--------------------------------------
Changes (by Andrew Wilson):

* Attachment "after.png" added.

Django

unread,
Feb 22, 2018, 7:49:35 AM2/22/18
to django-...@googlegroups.com
#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 | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Herbert Fortes):

* cc: Herbert Fortes (added)
* stage: Unreviewed => Ready for checkin


Comment:

Hi,

IMHO it is a good idea.

Assign the ticket to yourself and do the PR.

Regards,
Herbert

--
Ticket URL: <https://code.djangoproject.com/ticket/29150#comment:1>

Django

unread,
Feb 22, 2018, 8:41:14 AM2/22/18
to django-...@googlegroups.com
#29150: Pretty display of JSONField data in forms
-------------------------------------+-------------------------------------

Reporter: Andrew Wilson | Owner: (none)
Type: | Status: closed
Cleanup/optimization |
Component: contrib.postgres | Version: 2.0
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => duplicate
* has_patch: 1 => 0
* type: Uncategorized => Cleanup/optimization
* stage: Ready for checkin => Unreviewed


Comment:

Duplicate of #26482 (closed as wontfix).

--
Ticket URL: <https://code.djangoproject.com/ticket/29150#comment:2>

Reply all
Reply to author
Forward
0 new messages