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.
* Attachment "before.png" added.
* Attachment "after.png" added.
* 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>
* 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>