[Django] #33779: Add an encoder parameter to django.utils.html.json_script

12 views
Skip to first unread message

Django

unread,
Jun 13, 2022, 3:05:17 AM6/13/22
to django-...@googlegroups.com
#33779: Add an encoder parameter to django.utils.html.json_script
----------------------------------------+------------------------
Reporter: Claude Paroz | Owner: nobody
Type: New feature | Status: new
Component: Utilities | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+------------------------
I have a use case where I want to customize the JSON encoding of some
values to output to the template layer. It looks like
`django.utils.html.json_script` is a good utility for that, however the
JSON encoder is hardcoded to `DjangoJSONEncoder`. I think it would be nice
to be able to pass a custom encoder class.

By the way, `django.utils.html.json_script` is not documented (only its
template filter counterpart is), would it be a good thing to add to the
docs?

--
Ticket URL: <https://code.djangoproject.com/ticket/33779>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Reply all
Reply to author
Forward
0 new messages